From patchwork Mon May 7 06:20:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 909537 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40fXc95QxHz9s27 for ; Mon, 7 May 2018 16:23:05 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zy9a1PHp"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40fXc93jp9zF156 for ; Mon, 7 May 2018 16:23:05 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zy9a1PHp"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::241; helo=mail-pf0-x241.google.com; envelope-from=wei.guo.simon@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zy9a1PHp"; dkim-atps=neutral Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40fXYF5q2czF14g for ; Mon, 7 May 2018 16:20:33 +1000 (AEST) Received: by mail-pf0-x241.google.com with SMTP id v63so22017044pfk.8 for ; Sun, 06 May 2018 23:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=8F7/Ak4tiKmmXq00sZ8Y66QUwBCucOWCaLZ+gjlQ7Qw=; b=Zy9a1PHp6VO0RNmTTDqs8d27L2hVZ65qR4m5zJEQOU0UiB5Boiw8CJYyfI1uqeSJkE sNQCNPDqzr7W228IXjBeRViFiMYxWXuhGyBRwfLpFd737JqPAIwcQDIJTND96KIP0qBC VVIxhrtMLspUB2IOqKV7nuJGb2LE25hL+sHM3kPrk15Ph3XXW9Iui9HnKb4lMu1hYMG8 ucxaoW7z3bzy2MlO1/M4Sp/yTEd+uIFp2Ld77LHdO7Idmvhos3G8fR76Q2/P2cmjFZMM wGsg2hTFaE+Ka1t4lsCcF+Nnihz4+jlmIu+1n/MQoc+Ea/WKzNIMAFk6Y820h6X2xUEL AwIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8F7/Ak4tiKmmXq00sZ8Y66QUwBCucOWCaLZ+gjlQ7Qw=; b=WnKXkmwnaUY3YzB8wl08CNQHxqZrFP1FIuQyfINZ7mNWFyYgZcD52Smo4NFxbb2HFi VGeMph0mfon+a80rZoE6TikHCDhWd30ie79Jpw/7+42DfJYKtWTiS/Xnuc8jZ9k7Yx36 uPdl1h6edO/ijSMspCOAYccBeXfQxAatw7U7gw+CRXmruH/jqsFVoDEApbI+ZMeM80nP GAHJ5mG4DC7AKODPBR+rsoOJYXjEdAHLcvUbJit3T3XwDexx9NQJU+ctqdZbaZ+8TvDL MvtTEcjMbhyAz7vDHD1IUuTmPbTT796mk0LYTHD4W5q2Z4F/10ST/r6VcgwpQkYdwwgS IMTg== X-Gm-Message-State: ALQs6tB80Jz7Y2yD9GjfWuJVSvWANkbNmjiVGoBowQBWIlFWvmQT/fiU PJPDR396C6P+8eGdFXzyZ9g= X-Google-Smtp-Source: AB8JxZoui5UlxVs7PxIFv2JmQ4gFn/yf4VKqv1qtV9Smijh1Es9mMwh7sMQWyS/R4PwtsEXs9olGlQ== X-Received: by 10.98.200.152 with SMTP id i24mr35921178pfk.35.1525674031196; Sun, 06 May 2018 23:20:31 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([112.73.0.88]) by smtp.gmail.com with ESMTPSA id z25sm10459544pfi.171.2018.05.06.23.20.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 May 2018 23:20:30 -0700 (PDT) From: wei.guo.simon@gmail.com To: kvm-ppc@vger.kernel.org Subject: [PATCH v2 00/10] KVM: PPC: reimplement mmio emulation with analyse_instr() Date: Mon, 7 May 2018 14:20:06 +0800 Message-Id: <1525674016-6703-1-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Simon Guo , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Simon Guo We already have analyse_instr() which analyzes instructions for the instruction type, size, addtional flags, etc. What kvmppc_emulate_loadstore() did is somehow duplicated and it will be good to utilize analyse_instr() to reimplement the code. The advantage is that the code logic will be shared and more clean to be maintained. This patch series reimplement kvmppc_emulate_loadstore() for various load/store instructions. The testcase locates at: https://github.com/justdoitqd/publicFiles/blob/master/test_mmio.c - Tested at both PR/HV KVM. - Also tested with little endian host & big endian guest. Tested instruction list: lbz lbzu lbzx ld ldbrx ldu ldx lfd lfdu lfdx lfiwax lfiwzx lfs lfsu lfsx lha lhau lhax lhbrx lhz lhzu lhzx lvx lwax lwbrx lwz lwzu lwzx lxsdx lxsiwax lxsiwzx lxsspx lxvd2x lxvdsx lxvw4x stb stbu stbx std stdbrx stdu stdx stfd stfdu stfdx stfiwx stfs stfsx sth sthbrx sthu sthx stvx stw stwbrx stwu stwx stxsdx stxsiwx stxsspx stxvd2x stxvw4x lvebx stvebx lvehx stvehx lvewx stvewx V2 changes: 1) correct patch split issue in v1. 2) revise some commit message/code comment per review comment 3) remove incorrect special handling for stxsiwx 4) remove mmio_update_ra related and move the RA update into kvmppc_emulate_loadstore(). 5) rework giveup_ext() which is only meaningful when not NULL. 6) rewrite VMX emulation code and cover rest VMX instructions: lvebx stvebx lvehx stvehx lvewx stvewx Simon Guo (10): KVM: PPC: add pt_regs into kvm_vcpu_arch and move vcpu->arch.gpr[] into it KVM: PPC: mov nip/ctr/lr/xer registers to pt_regs in kvm_vcpu_arch KVM: PPC: Fix a mmio_host_swabbed uninitialized usage issue when VMX store KVM: PPC: add KVMPPC_VSX_COPY_WORD_LOAD_DUMP type support for mmio emulation KVM: PPC: reimplement non-SIMD LOAD/STORE instruction mmio emulation with analyse_intr() input KVM: PPC: add giveup_ext() hook for PPC KVM ops KVM: PPC: reimplement LOAD_FP/STORE_FP instruction mmio emulation with analyse_intr() input KVM: PPC: reimplements LOAD_VSX/STORE_VSX instruction mmio emulation with analyse_intr() input KVM: PPC: expand mmio_vsx_copy_type to mmio_copy_type to cover VMX load/store elem types KVM: PPC: reimplements LOAD_VMX/STORE_VMX instruction mmio emulation with analyse_intr() input arch/powerpc/include/asm/kvm_book3s.h | 20 +- arch/powerpc/include/asm/kvm_book3s_64.h | 20 +- arch/powerpc/include/asm/kvm_booke.h | 20 +- arch/powerpc/include/asm/kvm_host.h | 17 +- arch/powerpc/include/asm/kvm_ppc.h | 17 +- arch/powerpc/kernel/asm-offsets.c | 18 +- arch/powerpc/kvm/book3s.c | 4 +- arch/powerpc/kvm/book3s_32_mmu.c | 2 +- arch/powerpc/kvm/book3s_64_vio_hv.c | 2 +- arch/powerpc/kvm/book3s_hv.c | 6 +- arch/powerpc/kvm/book3s_hv_builtin.c | 6 +- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 15 +- arch/powerpc/kvm/book3s_hv_rm_xics.c | 2 +- arch/powerpc/kvm/book3s_hv_tm.c | 10 +- arch/powerpc/kvm/book3s_hv_tm_builtin.c | 10 +- arch/powerpc/kvm/book3s_pr.c | 73 +-- arch/powerpc/kvm/book3s_xive_template.c | 4 +- arch/powerpc/kvm/booke.c | 41 +- arch/powerpc/kvm/booke_emulate.c | 6 +- arch/powerpc/kvm/e500_emulate.c | 6 +- arch/powerpc/kvm/e500_mmu.c | 2 +- arch/powerpc/kvm/e500_mmu_host.c | 8 +- arch/powerpc/kvm/emulate_loadstore.c | 746 +++++++++---------------------- arch/powerpc/kvm/powerpc.c | 299 ++++++++++--- 24 files changed, 628 insertions(+), 726 deletions(-)