lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 21 Oct 2019 19:28:48 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Anup Patel <Anup.Patel@....com>,
        Palmer Dabbelt <palmer@...ive.com>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        Radim K <rkrcmar@...hat.com>
Cc:     Daniel Lezcano <daniel.lezcano@...aro.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Alexander Graf <graf@...zon.com>,
        Atish Patra <Atish.Patra@....com>,
        Alistair Francis <Alistair.Francis@....com>,
        Damien Le Moal <Damien.LeMoal@....com>,
        Christoph Hellwig <hch@...radead.org>,
        Anup Patel <anup@...infault.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v9 19/22] RISC-V: KVM: Remove per-CPU vsip_shadow variable

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 <anup.patel@....com>

Please squash this and patch 20 into the corresponding patches earlier
in the series.

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)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ