Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5159481ybg; Mon, 21 Oct 2019 22:14:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrQWjWUsDUFEDFkgJNMBF0czpAbO+nsBnVJ4xGxEqtKpmvm90wLGhiXIOZM8beEyWz7WIW X-Received: by 2002:a50:b6cb:: with SMTP id f11mr2677843ede.299.1571721246267; Mon, 21 Oct 2019 22:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571721246; cv=none; d=google.com; s=arc-20160816; b=Z668LiskWwqAxI8aK0J1cyDplTzxmFMPZNTLZvFB1De0MRxQYlE+deJ9WhULvpg5c7 MdUwVasnb/eb4Uu9isBt5mhkx7Eq+Mk6knoGPKQ/zZ/qokeucnTMJbBsFSvfUuqe2kWr sAGg7I6fmhlTunwgzJNL3ha+xi3idY4i/2Oo7pEShItxop3NWFdO0O/gNzi/xCnpOqnL BCnjzgvNAXsjcvysSUch2mSBfDAOJtzlMUbUEVe2HvdVfa3uJ3EbGarLSqHv7Se8AuWb swJKc8f3HPKFvXV2DvquZhHKEuScjz8t0OKy6ubVnjm7pOqXl6XhWh3RdNGKyxExVvyZ /8Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=u/quP6H3t0vd+EUHeiV1XtwPAgHpe/L6SdgFukt3v7I=; b=jygp/T2jIU+CTJFFkTfXobmmmDFoa6fGLJS6lydhZeVGi86z5pwnrF9Hl6YOB34ppx s2RVgquyuFYm4LoJt5N7hgB8P5N4WsIOkFuWkDacMtgjKqrfjB86aOPcYj5+1pA1O6WM U5Bc6MKjM7ncYgT/W/5IXTj8kzg1ERRTEyVblEaHzBja3pskI3aqad4OxgwNYqM1eqNw /8HUgsdFFjLjZ39k+tZnOLRgTvqjamruSfjFaY29w4CSwbeT7attxLRBuKEZyr8K60iU vkVqD6CJlUzQjlVE94aU9zfeNypxtrlnJZZvAf702tD1r687iUN+EwqOCN6fEwVrVGOj 0u4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=UJDKA2KX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oz20si9704749ejb.436.2019.10.21.22.13.42; Mon, 21 Oct 2019 22:14:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=UJDKA2KX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731109AbfJVFJp (ORCPT + 99 others); Tue, 22 Oct 2019 01:09:45 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36224 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730978AbfJVFJo (ORCPT ); Tue, 22 Oct 2019 01:09:44 -0400 Received: by mail-wr1-f66.google.com with SMTP id w18so15831698wrt.3 for ; Mon, 21 Oct 2019 22:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u/quP6H3t0vd+EUHeiV1XtwPAgHpe/L6SdgFukt3v7I=; b=UJDKA2KXuJEpZjuCE7M0A4TYaHJwXeoBaS3iWDPtUSt7GpqUGQrS3O4k6DvdgSb0bN redzX4NV6SW/+egZUr2DuF4GQmoqZw7FDbnKJCBzFeU7rWxVQouA5kFncvAehzf3jKqK gdTnn7FZd+1uzTx9c+42X/rn+kUbhA3rerOGp02RJnWesekdrGx8kquK5lfH4pNSvvKR 8hVX21GmgbEXHn5F9CCMPTbdlfTnvqE7OfjMz7MWDEo2qd4NIV6VUFFGdpo6bdcurrUX vG60tTnjBqx+BZ1xWISIV0eIeEvBvPOMyy/oxA+ZGo7xMeMx3TYp231RgISwQayeJOpK MH+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u/quP6H3t0vd+EUHeiV1XtwPAgHpe/L6SdgFukt3v7I=; b=WFhVYGGlvdfGNDT2I5Z3eeirusQR/1yt3pxu6KeaWBcEAEI334ne1Zs707N7Up42gz 6KzY/KsV2hxT3tNW9zcs8UPUz7KNDUwnU23HQy62bD+O7/3fBaeACFCQ6LMbPnzWwIVJ zSvPowe925KXzIq84xI+vHsNwN/BGGnIAu0gMJrq8XHCm2u4Ape/rYPybs6hgsvrjCu8 CzgNuMf3165XE7pvM/cz/KdmvVBDC2QeM3/cJqEYbF5GLElnVJEQtyfyONfJ2wCPtaue Sc6RuFz1t/Lbub1mgAJrR/+XoxWfJat9UrJsR45ampda3arMf1ijbYenJDQSnY6AURbp NGdQ== X-Gm-Message-State: APjAAAX6aw9ilpFpyHrl7sOJgnfLQcCQIKyq4GAB/cj/3Lt7ZVZ2Whr1 fQI2YkoOZ30I6DK5ATQA1H1/4sXYMQzRpFF7WrNBfA== X-Received: by 2002:adf:e850:: with SMTP id d16mr1439791wrn.251.1571720981754; Mon, 21 Oct 2019 22:09:41 -0700 (PDT) MIME-Version: 1.0 References: <20191016160649.24622-1-anup.patel@wdc.com> <20191016160649.24622-20-anup.patel@wdc.com> <7381057d-a3f3-e79a-bb2c-b078fc918b1f@redhat.com> In-Reply-To: <7381057d-a3f3-e79a-bb2c-b078fc918b1f@redhat.com> From: Anup Patel Date: Tue, 22 Oct 2019 10:39:30 +0530 Message-ID: Subject: Re: [PATCH v9 19/22] RISC-V: KVM: Remove per-CPU vsip_shadow variable To: Paolo Bonzini Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Radim K , Daniel Lezcano , Thomas Gleixner , Alexander Graf , Atish Patra , Alistair Francis , Damien Le Moal , Christoph Hellwig , "kvm@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 21, 2019 at 10:58 PM Paolo Bonzini wrote: > > On 16/10/19 18:12, Anup Patel wrote: > > Currently, we track last value wrote to VSIP CSR using per-CPU > > vsip_shadow variable but this easily goes out-of-sync because > > Guest can update VSIP.SSIP bit directly. > > > > To simplify things, we remove per-CPU vsip_shadow variable and > > unconditionally write vcpu->arch.guest_csr.vsip to VSIP CSR in > > run-loop. > > > > Signed-off-by: Anup Patel > > Please squash this and patch 20 into the corresponding patches earlier > in the series. Sure, I will squash patch20 and patch19 onto patch5. Regards, Anup > > Paolo > > > --- > > arch/riscv/include/asm/kvm_host.h | 3 --- > > arch/riscv/kvm/main.c | 6 ------ > > arch/riscv/kvm/vcpu.c | 24 +----------------------- > > 3 files changed, 1 insertion(+), 32 deletions(-) > > > > diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h > > index ec1ca4bc98f2..cd86acaed055 100644 > > --- a/arch/riscv/include/asm/kvm_host.h > > +++ b/arch/riscv/include/asm/kvm_host.h > > @@ -202,9 +202,6 @@ static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} > > static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {} > > static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {} > > > > -int kvm_riscv_setup_vsip(void); > > -void kvm_riscv_cleanup_vsip(void); > > - > > #define KVM_ARCH_WANT_MMU_NOTIFIER > > int kvm_unmap_hva_range(struct kvm *kvm, > > unsigned long start, unsigned long end); > > diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c > > index 55df85184241..002301a27d29 100644 > > --- a/arch/riscv/kvm/main.c > > +++ b/arch/riscv/kvm/main.c > > @@ -61,17 +61,11 @@ void kvm_arch_hardware_disable(void) > > > > int kvm_arch_init(void *opaque) > > { > > - int ret; > > - > > if (!riscv_isa_extension_available(NULL, h)) { > > kvm_info("hypervisor extension not available\n"); > > return -ENODEV; > > } > > > > - ret = kvm_riscv_setup_vsip(); > > - if (ret) > > - return ret; > > - > > kvm_riscv_stage2_vmid_detect(); > > > > kvm_info("hypervisor extension available\n"); > > diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c > > index fd77cd39dd8c..f1a218d3a8cf 100644 > > --- a/arch/riscv/kvm/vcpu.c > > +++ b/arch/riscv/kvm/vcpu.c > > @@ -111,8 +111,6 @@ static void kvm_riscv_vcpu_host_fp_restore(struct kvm_cpu_context *cntx) {} > > riscv_isa_extension_mask(s) | \ > > riscv_isa_extension_mask(u)) > > > > -static unsigned long __percpu *vsip_shadow; > > - > > static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu) > > { > > struct kvm_vcpu_csr *csr = &vcpu->arch.guest_csr; > > @@ -765,7 +763,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, > > void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > > { > > struct kvm_vcpu_csr *csr = &vcpu->arch.guest_csr; > > - unsigned long *vsip = raw_cpu_ptr(vsip_shadow); > > > > csr_write(CSR_VSSTATUS, csr->vsstatus); > > csr_write(CSR_VSIE, csr->vsie); > > @@ -775,7 +772,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > > csr_write(CSR_VSCAUSE, csr->vscause); > > csr_write(CSR_VSTVAL, csr->vstval); > > csr_write(CSR_VSIP, csr->vsip); > > - *vsip = csr->vsip; > > csr_write(CSR_VSATP, csr->vsatp); > > > > kvm_riscv_stage2_update_hgatp(vcpu); > > @@ -843,26 +839,8 @@ static void kvm_riscv_check_vcpu_requests(struct kvm_vcpu *vcpu) > > static void kvm_riscv_update_vsip(struct kvm_vcpu *vcpu) > > { > > struct kvm_vcpu_csr *csr = &vcpu->arch.guest_csr; > > - unsigned long *vsip = raw_cpu_ptr(vsip_shadow); > > - > > - if (*vsip != csr->vsip) { > > - csr_write(CSR_VSIP, csr->vsip); > > - *vsip = csr->vsip; > > - } > > -} > > - > > -int kvm_riscv_setup_vsip(void) > > -{ > > - vsip_shadow = alloc_percpu(unsigned long); > > - if (!vsip_shadow) > > - return -ENOMEM; > > > > - return 0; > > -} > > - > > -void kvm_riscv_cleanup_vsip(void) > > -{ > > - free_percpu(vsip_shadow); > > + csr_write(CSR_VSIP, csr->vsip); > > } > > > > int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) > > >