From patchwork Wed Apr 25 11:54:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 904189 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 40WJvS14kzz9rxs for ; Wed, 25 Apr 2018 22:11:16 +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="T/AueYU9"; 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 40WJvR5vbtzF24L for ; Wed, 25 Apr 2018 22:11:15 +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="T/AueYU9"; 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:c05::241; helo=mail-pg0-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="T/AueYU9"; dkim-atps=neutral Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::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 40WJY20lqxzF24t for ; Wed, 25 Apr 2018 21:55:17 +1000 (AEST) Received: by mail-pg0-x241.google.com with SMTP id e12so13166941pgn.9 for ; Wed, 25 Apr 2018 04:55:17 -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:in-reply-to:references; bh=KmLIuinPc5Ez0NsKBl+0Qsr8A9mFas2C3H1yVJoMDMw=; b=T/AueYU9KP5MvVSCtzPVv7DnyUuPuBGKbi/dgmVo0Qcw2FSRW3SdZ+24tPiHw3bE6z lKslSW1FJYoJlIOJ9vt/HbytOFZr9fljvIm2+lmkNq7uuSXlA0GvvePGbQgYmfmkNtCx A0BFZAq46Yl/o58iv0bNAAz+aXmEvwpk+XlNC8QOjPZw3RqhINb++NbnCEQ26rNFk3PY JiMZvtcsm51yNB+4MTiYQ64vIfcFQm65ijsNJ1gQ/6JM8cBDeM7+hpeR05+Kw86GAWCv Scv0VbdNjWDGJQwnDL6h1YSFqiT8tfZVlLhTERh4RkvxQd0pQIbk3IHYPQ5wW3soS4dX 9+Aw== 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:in-reply-to :references; bh=KmLIuinPc5Ez0NsKBl+0Qsr8A9mFas2C3H1yVJoMDMw=; b=gkU5sc+gZWNHU7oX4NaPbsyUzLOPriHuqqnxySOLR4i/9DDBDon3fVHtiPP7tdc7cE RHDqwYYTv3VQvKOLt/ARPTvyA5d80YDM5SWN9bpLUuR8IcDcGxy0YCCBQJ9/Q18GrUuh wIQ2tGAtdSmrJ//exPKX0V0GIkFGvbypYlNGzdtsFex1ydpFGPAjxUjWHXzapIWkhQW2 1JEfPPIsjigyTkIIWA+MpMkdifN1Hn6aYavHdMy/7Mv1NrN4p4GmjOMPmdFDbxqW5+hg Mf/dlJKS4R5gS2qgtVxiMu7+UOqkoWi7R8srWXNV4e6D+bIseWIA7pCPMNui2YebUxls p4XQ== X-Gm-Message-State: ALQs6tBq5D2tWVzQsIgTb5CrEoMaZElnSTT8ISoqS0LF1HqC2Fe1gveK 0pqjT5Lq2FwrnfNjwEbeMaM= X-Google-Smtp-Source: AIpwx48f6PaRElZ4jU1C8PgbIT9fod+zHP+l0FmKJNDEehhHmLn97aQEmNhDB/ofvLsLBBYugice0g== X-Received: by 10.99.111.65 with SMTP id k62mr23146633pgc.73.1524657313870; Wed, 25 Apr 2018 04:55:13 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([112.73.0.87]) by smtp.gmail.com with ESMTPSA id j1sm30912934pgn.69.2018.04.25.04.55.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 04:55:13 -0700 (PDT) From: wei.guo.simon@gmail.com To: kvm-ppc@vger.kernel.org Subject: [PATCH 05/11] KVM: PPC: add GPR RA update skeleton for MMIO emulation Date: Wed, 25 Apr 2018 19:54:38 +0800 Message-Id: <1524657284-16706-6-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1524657284-16706-1-git-send-email-wei.guo.simon@gmail.com> References: <1524657284-16706-1-git-send-email-wei.guo.simon@gmail.com> 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 To optimize kvm emulation code with analyse_instr, adds new mmio_update_ra flag to aid with GPR RA update. This patch arms RA update at load/store emulation path for both qemu mmio emulation or coalesced mmio emulation. Signed-off-by: Simon Guo --- arch/powerpc/include/asm/kvm_host.h | 2 ++ arch/powerpc/kvm/emulate_loadstore.c | 1 + arch/powerpc/kvm/powerpc.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 2d87768..1c7da00 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -673,6 +673,8 @@ struct kvm_vcpu_arch { u8 mmio_sign_extend; /* conversion between single and double precision */ u8 mmio_sp64_extend; + u8 mmio_ra; /* GPR as ra to be updated with EA */ + u8 mmio_update_ra; /* * Number of simulations for vsx. * If we use 2*8bytes to simulate 1*16bytes, diff --git a/arch/powerpc/kvm/emulate_loadstore.c b/arch/powerpc/kvm/emulate_loadstore.c index b8a3aef..90b9692 100644 --- a/arch/powerpc/kvm/emulate_loadstore.c +++ b/arch/powerpc/kvm/emulate_loadstore.c @@ -111,6 +111,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu) vcpu->arch.mmio_sp64_extend = 0; vcpu->arch.mmio_sign_extend = 0; vcpu->arch.mmio_vmx_copy_nums = 0; + vcpu->arch.mmio_update_ra = 0; vcpu->arch.mmio_host_swabbed = 0; switch (get_op(inst)) { diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index bef27b1..f7fd68f 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -1111,6 +1111,12 @@ static int __kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu, if (!ret) { kvmppc_complete_mmio_load(vcpu, run); + if (vcpu->arch.mmio_update_ra) { + kvmppc_set_gpr(vcpu, vcpu->arch.mmio_ra, + vcpu->arch.vaddr_accessed); + vcpu->arch.mmio_update_ra = 0; + } + vcpu->mmio_needed = 0; return EMULATE_DONE; } @@ -1215,6 +1221,12 @@ int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu, if (!ret) { vcpu->mmio_needed = 0; + if (vcpu->arch.mmio_update_ra) { + kvmppc_set_gpr(vcpu, vcpu->arch.mmio_ra, + vcpu->arch.vaddr_accessed); + vcpu->arch.mmio_update_ra = 0; + } + return EMULATE_DONE; } @@ -1581,6 +1593,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) } } #endif + if (vcpu->arch.mmio_update_ra) { + kvmppc_set_gpr(vcpu, vcpu->arch.mmio_ra, + vcpu->arch.vaddr_accessed); + vcpu->arch.mmio_update_ra = 0; + } } else if (vcpu->arch.osi_needed) { u64 *gprs = run->osi.gprs; int i;