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] [day] [month] [year] [list]
Message-ID:
 <TY1PPFCDFFFA68A2A32AC6CAE356148712CF332A@TY1PPFCDFFFA68A.apcprd02.prod.outlook.com>
Date: Thu, 21 Aug 2025 16:22:17 +0800
From: "Nutty.Liu" <nutty.liu@...mail.com>
To: Jinyu Tang <tjytimi@....com>, Anup Patel <anup@...infault.org>,
 Atish Patra <atish.patra@...ux.dev>,
 Conor Dooley <conor.dooley@...rochip.com>,
 Yong-Xuan Wang <yongxuan.wang@...ive.com>,
 Paul Walmsley <paul.walmsley@...ive.com>
Cc: kvm@...r.kernel.org, kvm-riscv@...ts.infradead.org,
 linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv: skip csr restore if vcpu preempted reload


On 8/7/2025 7:42 PM, Jinyu Tang wrote:
> The kvm_arch_vcpu_load() function is called in two cases for riscv:
> 1. When entering KVM_RUN from userspace ioctl.
> 2. When a preempted VCPU is scheduled back.
>
> In the second case, if no other KVM VCPU has run on this CPU since the
> current VCPU was preempted, the guest CSR values are still valid in
> the hardware and do not need to be restored.
>
> This patch is to skip the CSR write path when:
> 1. The VCPU was previously preempted
> (vcpu->scheduled_out == 1).
> 2. It is being reloaded on the same physical CPU
> (vcpu->arch.last_exit_cpu == cpu).
> 3. No other KVM VCPU has used this CPU in the meantime
> (vcpu == __this_cpu_read(kvm_former_vcpu)).
>
> This reduces many CSR writes with frequent preemption on the same CPU.
>
> Signed-off-by: Jinyu Tang <tjytimi@....com>
> ---
>   arch/riscv/kvm/vcpu.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
Reviewed-by: Nutty Liu <nutty.liu@...mail.com>

Thanks,
Nutty

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ