Re: [PATCH v5 5/7] KVM: arm64: Always set HCR_TID2

2023-01-05 Thread Reiji Watanabe
= read_sysreg_el1(SYS_TTBR0); > @@ -95,7 +94,6 @@ static inline void __sysreg_restore_user_state(struct > kvm_cpu_context *ctxt) > static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt) > { > write_sysreg(ctxt_sys_reg(ctxt, MPIDR_EL1), vmpidr_el2);

Re: [PATCH 0/7] KVM: arm64: PMU: Allow userspace to limit the number of PMCs on vCPU

2023-01-04 Thread Reiji Watanabe
Hi Jonathan, On Tue, Jan 3, 2023 at 4:47 AM Marc Zyngier wrote: > > On Tue, 03 Jan 2023 12:40:34 +, > Jonathan Cameron wrote: > > > > On Thu, 29 Dec 2022 19:59:21 -0800 > > Reiji Watanabe wrote: > > > > > The goal of this series is to allow usersp

[PATCH 7/7] KVM: selftests: aarch64: vPMU register test for unimplemented counters

2022-12-29 Thread Reiji Watanabe
Add a new test case to the vpmu_counter_access test to check if PMU registers or their bits for unimplemented counters are not accessible or are RAZ, as expected. Signed-off-by: Reiji Watanabe --- .../kvm/aarch64/vpmu_counter_access.c | 103 +- .../selftests/kvm/include

[PATCH 6/7] KVM: selftests: aarch64: vPMU register test for implemented counters

2022-12-29 Thread Reiji Watanabe
Add a new test case to the vpmu_counter_access test to check if PMU registers or their bits for implemented counters on the vCPU are readable/writable as expected, and can be programmed to count events. Signed-off-by: Reiji Watanabe --- .../kvm/aarch64/vpmu_counter_access.c | 347

[PATCH 5/7] KVM: selftests: aarch64: Introduce vpmu_counter_access test

2022-12-29 Thread Reiji Watanabe
is equal to or less than PMCR_EL1.N on the host. Signed-off-by: Reiji Watanabe --- tools/testing/selftests/kvm/.gitignore| 1 + tools/testing/selftests/kvm/Makefile | 1 + .../kvm/aarch64/vpmu_counter_access.c | 181 ++ 3 files changed, 183 insertions

[PATCH 4/7] tools: arm64: Import perf_event.h

2022-12-29 Thread Reiji Watanabe
Copy perf_event.h from the kernel's arch/arm64/include/asm/perf_event.h. The following patches will use macros defined in this header. Signed-off-by: Reiji Watanabe --- tools/arch/arm64/include/asm/perf_event.h | 258 ++ 1 file changed, 258 insertions(+) create mode 1

[PATCH 3/7] KVM: arm64: PMU: Preserve vCPU's PMCR_EL0.N value on vCPU reset

2022-12-29 Thread Reiji Watanabe
reset_pmcr() resets PMCR_EL0.N to the host value on vCPU reset. Change reset_pmcr() to preserve the vCPU's PMCR_EL0.N value on vCPU reset so that userspace can limit the number of the PMU event counter on the vCPU. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/pmu-emul.c | 6 ++ arch/

[PATCH 2/7] KVM: arm64: PMU: Use reset_pmu_reg() for PMUSERENR_EL0 and PMCCFILTR_EL0

2022-12-29 Thread Reiji Watanabe
The default reset function for PMU registers (reset_pmu_reg()) now simply clears a specified register. Use that function for PMUSERENR_EL0 and PMCCFILTR_EL0, since those registers should simply be cleared on vCPU reset. No functional change intended. Signed-off-by: Reiji Watanabe --- arch

[PATCH 1/7] KVM: arm64: PMU: Have reset_pmu_reg() to clear a register

2022-12-29 Thread Reiji Watanabe
RAZ bits of those registers could end up being set to 1). Fix reset_pmu_reg() to clear the registers so that it can ensure that all the RAZ bits are cleared even when the PMCR_EL1.N value for the vCPU is different from the host value. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c

[PATCH 0/7] KVM: arm64: PMU: Allow userspace to limit the number of PMCs on vCPU

2022-12-29 Thread Reiji Watanabe
es at the following commit: commit aff234839f8b ("KVM: arm64: PMU: Fix PMCR_EL0 reset value") Reiji Watanabe (7): KVM: arm64: PMU: Have reset_pmu_reg() to clear a register KVM: arm64: PMU: Use reset_pmu_reg() for PMUSERENR_EL0 and PMCCFILTR_EL0 KVM: arm64: PMU: Preserve vC

Re: [PATCH v4 13/16] KVM: arm64: PMU: Implement PMUv3p5 long counter support

2022-11-28 Thread Reiji Watanabe
Hi Marc, On Thu, Nov 24, 2022 at 2:17 AM Marc Zyngier wrote: > > On Wed, 23 Nov 2022 17:11:41 +0000, > Reiji Watanabe wrote: > > > > Hi Marc, > > > > On Wed, Nov 23, 2022 at 3:11 AM Marc Zyngier wrote: > > > > > > On Wed, 23 N

Re: [PATCH v4 13/16] KVM: arm64: PMU: Implement PMUv3p5 long counter support

2022-11-23 Thread Reiji Watanabe
Hi Marc, On Wed, Nov 23, 2022 at 3:11 AM Marc Zyngier wrote: > > On Wed, 23 Nov 2022 05:58:17 +0000, > Reiji Watanabe wrote: > > > > Hi Marc, > > > > On Sun, Nov 13, 2022 at 8:46 AM Marc Zyngier wrote: > > > > > > PMUv3p5 (which is mandatory

Re: [PATCH v4 15/16] KVM: arm64: PMU: Simplify vcpu computation on perf overflow notification

2022-11-22 Thread Reiji Watanabe
step and directly compute the target > vcpu. > > Signed-off-by: Marc Zyngier Reviewed-by: Reiji Watanabe ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v4 14/16] KVM: arm64: PMU: Allow PMUv3p5 to be exposed to the guest

2022-11-22 Thread Reiji Watanabe
On Sun, Nov 13, 2022 at 8:46 AM Marc Zyngier wrote: > > Now that the infrastructure is in place, bump the PMU support up > to PMUv3p5. > > Signed-off-by: Marc Zyngier Reviewed-by: Reiji Watanabe ___ kvmarm mailing list kvmarm@lists.

Re: [PATCH v4 13/16] KVM: arm64: PMU: Implement PMUv3p5 long counter support

2022-11-22 Thread Reiji Watanabe
Hi Marc, On Sun, Nov 13, 2022 at 8:46 AM Marc Zyngier wrote: > > PMUv3p5 (which is mandatory with ARMv8.5) comes with some extra > features: > > - All counters are 64bit > > - The overflow point is controlled by the PMCR_EL0.LP bit > > Add the required checks in the helpers that control counter >

Re: [PATCH v4 12/16] KVM: arm64: PMU: Allow ID_DFR0_EL1.PerfMon to be set from userspace

2022-11-18 Thread Reiji Watanabe
IMP_DEF (I have the same comment for pmuver_to_perfmon in the patch-10). > + default: > + /* Anything ARMv8.1+ has the same value. For now. */ Nit: Shouldn't the comment also mention NI (and IMP_DEF) ? (I have the same comment for pmuver_to_perfmon in the

Re: [PATCH v4 11/16] KVM: arm64: PMU: Allow ID_AA64DFR0_EL1.PMUver to be set from userspace

2022-11-18 Thread Reiji Watanabe
On Sun, Nov 13, 2022 at 8:46 AM Marc Zyngier wrote: > > Allow userspace to write ID_AA64DFR0_EL1, on the condition that only > the PMUver field can be altered and be at most the one that was > initially computed for the guest. > > Signed-off-by: Marc Zyngier Reviewed-

Re: [PATCH v4 09/16] KVM: arm64: PMU: Do not let AArch32 change the counters' top 32 bits

2022-11-17 Thread Reiji Watanabe
Hi Marc, On Sun, Nov 13, 2022 at 8:38 AM Marc Zyngier wrote: > > Even when using PMUv3p5 (which implies 64bit counters), there is > no way for AArch32 to write to the top 32 bits of the counters. > The only way to influence these bits (other than by counting > events) is by writing PMCR.P==1. > >

Re: [PATCH v4 07/16] KVM: arm64: PMU: Add counter_index_to_*reg() helpers

2022-11-17 Thread Reiji Watanabe
Hi Marc, On Sun, Nov 13, 2022 at 8:38 AM Marc Zyngier wrote: > > In order to reduce the boilerplate code, add two helpers returning > the counter register index (resp. the event register) in the vcpu > register file from the counter index. > > Reviewed-by: Oliver Upton > Signed-off-by: Marc Zyng

Re: [PATCH 2/2] KVM: arm64: selftests: Disable single-step without relying on ucall()

2022-11-16 Thread Reiji Watanabe
n. > > Link: https://lore.kernel.org/all/20221006003409.649993-8-sea...@google.com > Cc: Oliver Upton > Cc: Marc Zyngier > Signed-off-by: Sean Christopherson Reviewed-by: Reiji Watanabe ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v4 06/16] KVM: arm64: PMU: Only narrow counters that are not 64bit wide

2022-11-16 Thread Reiji Watanabe
pens unconditionally. > > Signed-off-by: Marc Zyngier Reviewed-by: Reiji Watanabe ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v4 05/16] KVM: arm64: PMU: Narrow the overflow checking when required

2022-11-16 Thread Reiji Watanabe
ow(vcpu, i) ? reg : > lower_32_bits(reg)) A few lines up, the 'reg' is unconditionally updated with "lower_32_bits(reg)". So, the change initially confused me (until I checked the following patch). IMHO it might be more clear if this patch and the next pa

Re: [PATCH 1/2] KVM: arm64: selftests: Disable single-step with correct KVM define

2022-11-16 Thread Reiji Watanabe
tively disables single-step debug. > > No functional change intended. > > Cc: Reiji Watanabe > Fixes: b18e4d4aebdd ("KVM: arm64: selftests: Add a test case for > KVM_GUESTDBG_SINGLESTEP") > Signed-off-by: Sean Christopherson > --- > tools/testing/selftests/kvm

Re: [PATCH v4 02/16] KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode

2022-11-15 Thread Reiji Watanabe
and "canonical counter". > The code is further restructured to make the CHAIN handling similar > to SWINC, as the two are now extremely similar in behaviour. > > Reported-by: Ricardo Koller > Signed-off-by: Marc Zyngier Reviewed-by: Reiji Watanabe __

Re: [PATCH v3 02/14] KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode

2022-11-12 Thread Reiji Watanabe
Hi Marc, > > > +#define PERF_ATTR_CFG1_COUNTER_64BIT BIT(0) > > > > Although this isn't the new code (but just a name change), > > wouldn't it be nicer to have armv8pmu_event_is_64bit() > > (in arch/arm64/kernel/perf_event.c) use the macro as well ? > > We tried that in the past, and the amount

Re: [PATCH v2 03/14] KVM: arm64: PMU: Always advertise the CHAIN event

2022-11-12 Thread Reiji Watanabe
; > Signed-off-by: Marc Zyngier Reviewed-by: Reiji Watanabe ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v3 02/14] KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode

2022-11-11 Thread Reiji Watanabe
Hi Marc, On Mon, Nov 7, 2022 at 12:54 AM Marc Zyngier wrote: > > Ricardo recently pointed out that the PMU chained counter emulation > in KVM wasn't quite behaving like the one on actual hardware, in > the sense that a chained counter would expose an overflow on > both halves of a chained counter

Re: [PATCH v3 11/14] KVM: arm64: PMU: Allow ID_AA64DFR0_EL1.PMUver to be set from userspace

2022-11-07 Thread Reiji Watanabe
Hi Marc, On Mon, Nov 7, 2022 at 1:16 AM Marc Zyngier wrote: > > Allow userspace to write ID_AA64DFR0_EL1, on the condition that only > the PMUver field can be altered and be at most the one that was > initially computed for the guest. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/sys_r

Re: [PATCH v2 11/14] KVM: arm64: PMU: Allow ID_AA64DFR0_EL1.PMUver to be set from userspace

2022-11-07 Thread Reiji Watanabe
Hi Marc, > > BTW, if we have no intention of supporting a mix of vCPUs with and > > without PMU, I think it would be nice if we have a clear comment on > > that in the code. Or I'm hoping to disallow it if possible though. > > I'm not sure we're in a position to do this right now. The current API

Re: [PATCH v2 11/14] KVM: arm64: PMU: Allow ID_AA64DFR0_EL1.PMUver to be set from userspace

2022-11-04 Thread Reiji Watanabe
Hi Marc, On Fri, Nov 4, 2022 at 5:21 AM Marc Zyngier wrote: > > Hi Reiji, > > On Fri, 04 Nov 2022 07:00:22 +0000, > Reiji Watanabe wrote: > > > > On Thu, Nov 3, 2022 at 3:25 AM Marc Zyngier wrote: > > > > > > On Thu, 03 Nov 2022 05:31:56 +, &g

Re: [PATCH v2 11/14] KVM: arm64: PMU: Allow ID_AA64DFR0_EL1.PMUver to be set from userspace

2022-11-04 Thread Reiji Watanabe
Hi Marc, On Thu, Nov 3, 2022 at 3:25 AM Marc Zyngier wrote: > > On Thu, 03 Nov 2022 05:31:56 +0000, > Reiji Watanabe wrote: > > > > Hi Marc, > > > > On Fri, Oct 28, 2022 at 4:16 AM Marc Zyngier wrote: > > > > > > Allow userspace to write ID

Re: [PATCH v2 10/14] KVM: arm64: PMU: Move the ID_AA64DFR0_EL1.PMUver limit to VM creation

2022-11-03 Thread Reiji Watanabe
Hi Marc, On Thu, Nov 3, 2022 at 1:44 AM Marc Zyngier wrote: > > Hi Reiji, > > On Thu, 03 Nov 2022 04:55:52 +0000, > Reiji Watanabe wrote: > > > > Hi Marc, > > > > On Fri, Oct 28, 2022 at 4:16 AM Marc Zyngier wrote: > > > > > > ca

Re: [PATCH v2 11/14] KVM: arm64: PMU: Allow ID_AA64DFR0_EL1.PMUver to be set from userspace

2022-11-02 Thread Reiji Watanabe
Hi Marc, On Fri, Oct 28, 2022 at 4:16 AM Marc Zyngier wrote: > > Allow userspace to write ID_AA64DFR0_EL1, on the condition that only > the PMUver field can be altered and be at most the one that was > initially computed for the guest. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/sys_

Re: [PATCH v2 10/14] KVM: arm64: PMU: Move the ID_AA64DFR0_EL1.PMUver limit to VM creation

2022-11-02 Thread Reiji Watanabe
Hi Marc, On Fri, Oct 28, 2022 at 4:16 AM Marc Zyngier wrote: > > As further patches will enable the selection of a PMU revision > from userspace, sample the supported PMU revision at VM creation > time, rather than building each time the ID_AA64DFR0_EL1 register > is accessed. > > This shouldn't

Re: [PATCH 6/9] KVM: arm64: PMU: Move the ID_AA64DFR0_EL1.PMUver limit to VM creation

2022-10-27 Thread Reiji Watanabe
Hi Marc, > Sorry it took so long to get back to this. No problem! > > On Fri, 26 Aug 2022 07:02:21 +0100, > Reiji Watanabe wrote: > > > > Hi Marc, > > > > On Thu, Aug 25, 2022 at 9:34 PM Reiji Watanabe wrote: > > > > > > Hi Marc, > >

Re: [PATCH 1/9] KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode

2022-10-27 Thread Reiji Watanabe
Hi Marc, > > > +static void kvm_pmu_counter_increment(struct kvm_vcpu *vcpu, > > > + unsigned long mask, u32 event) > > > +{ > > > + int i; > > > + > > > + if (!kvm_vcpu_has_pmu(vcpu)) > > > + return; > > > + > > > + if (!(__vcpu_

Re: [PATCH v2 1/9] KVM: arm64: selftests: Use FIELD_GET() to extract ID register fields

2022-10-20 Thread Reiji Watanabe
Hi Oliver, On Thu, Oct 20, 2022 at 12:08 PM Oliver Upton wrote: > > On Wed, Oct 19, 2022 at 10:41:54PM -0700, Reiji Watanabe wrote: > > Use FIELD_GET() macro to extract ID register fields for existing > > aarch64 selftests code. No functional change intended. > >

[PATCH v2 9/9] KVM: arm64: selftests: Test with every breakpoint/watchpoint

2022-10-19 Thread Reiji Watanabe
Currently, the debug-exceptions test always uses only {break,watch}point#0 and the highest numbered context-aware breakpoint. Modify the test to use all {break,watch}points and context-aware breakpoints supported on the system. Signed-off-by: Reiji Watanabe --- .../selftests/kvm/aarch64/debug

[PATCH v2 8/9] KVM: arm64: selftests: Add a test case for a linked watchpoint

2022-10-19 Thread Reiji Watanabe
aware breakpoint. Signed-off-by: Reiji Watanabe --- .../selftests/kvm/aarch64/debug-exceptions.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c index 362e766

[PATCH v2 7/9] KVM: arm64: selftests: Add a test case for a linked breakpoint

2022-10-19 Thread Reiji Watanabe
s the breakpoint#0 (for Address Match), which is linked to the context-aware breakpoint. Signed-off-by: Reiji Watanabe --- .../selftests/kvm/aarch64/debug-exceptions.c | 63 +-- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/

[PATCH v2 6/9] KVM: arm64: selftests: Change debug_version() to take ID_AA64DFR0_EL1

2022-10-19 Thread Reiji Watanabe
Change debug_version() to take the ID_AA64DFR0_EL1 value instead of vcpu as an argument, and change its callsite to read ID_AA64DFR0_EL1 (and pass it to debug_version()). Subsequent patches will reuse the register value in the callsite. No functional change intended. Signed-off-by: Reiji

[PATCH v2 5/9] KVM: arm64: selftests: Stop unnecessary test stage tracking of debug-exceptions

2022-10-19 Thread Reiji Watanabe
Currently, debug-exceptions test unnecessarily tracks some test stages using GUEST_SYNC(). The code for it needs to be updated as test cases are added or removed. Stop doing the unnecessary stage tracking, as they are not so useful and are a bit pain to maintain. Signed-off-by: Reiji Watanabe

[PATCH v2 4/9] KVM: arm64: selftests: Add helpers to enable debug exceptions

2022-10-19 Thread Reiji Watanabe
Add helpers to enable breakpoint and watchpoint exceptions. No functional change intended. Signed-off-by: Reiji Watanabe Reviewed-by: Ricardo Koller Reviewed-by: Oliver Upton --- .../selftests/kvm/aarch64/debug-exceptions.c | 25 ++- 1 file changed, 13 insertions(+), 12

[PATCH v2 3/9] KVM: arm64: selftests: Remove the hard-coded {b, w}pn#0 from debug-exceptions

2022-10-19 Thread Reiji Watanabe
{break,watch}points are specified for guest_code(). Subsequent patches will add test cases for non-zero {break,watch}points. Signed-off-by: Reiji Watanabe Reviewed-by: Ricardo Koller --- .../selftests/kvm/aarch64/debug-exceptions.c | 50 --- 1 file changed, 32 insertions(+), 18

[PATCH v2 2/9] KVM: arm64: selftests: Add write_dbg{b,w}{c,v}r helpers in debug-exceptions

2022-10-19 Thread Reiji Watanabe
Introduce helpers in the debug-exceptions test to write to dbg{b,w}{c,v}r registers. Those helpers will be useful for test cases that will be added to the test in subsequent patches. No functional change intended. Signed-off-by: Reiji Watanabe Reviewed-by: Ricardo Koller --- .../selftests

[PATCH v2 1/9] KVM: arm64: selftests: Use FIELD_GET() to extract ID register fields

2022-10-19 Thread Reiji Watanabe
Use FIELD_GET() macro to extract ID register fields for existing aarch64 selftests code. No functional change intended. Signed-off-by: Reiji Watanabe --- tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c | 3 ++- tools/testing/selftests/kvm/aarch64/debug-exceptions.c | 3 ++- tools/testing

[PATCH v2 0/9] KVM: arm64: selftests: Test linked {break, watch}points

2022-10-19 Thread Reiji Watanabe
/20220825050846.3418868-1-rei...@google.com/ [1] https://lore.kernel.org/all/20221017195834.2295901-6-ricar...@google.com/ Reiji Watanabe (9): KVM: arm64: selftests: Use FIELD_GET() to extract ID register fields KVM: arm64: selftests: Add write_dbg{b,w}{c,v}r helpers in debug-exceptions KVM

Re: [PATCH] KVM: arm64: Cleanup the __get_fault_info() to take out the code that validates HPFAR

2022-09-27 Thread Reiji Watanabe
Hi Mingwei, On Mon, Sep 26, 2022 at 5:27 PM Mingwei Zhang wrote: > > Cleanup __get_fault_info() to take out the code that checks HPFAR. The > conditions in __get_fault_info() that checks if HPFAR contains a valid IPA > is slightly messy in that several conditions are written within one IF > state

Re: [PATCH v2 4/4] KVM: arm64: selftests: Add a test case for KVM_GUESTDBG_SINGLESTEP

2022-09-19 Thread Reiji Watanabe
Hi Marc, On Mon, Sep 19, 2022 at 2:36 AM Marc Zyngier wrote: > > On Sat, 17 Sep 2022 02:06:00 +0100, > Reiji Watanabe wrote: > > > > Add a test case for KVM_GUESTDBG_SINGLESTEP to the debug-exceptions test. > > The test enables single-step execution from userspace, a

[PATCH v2 4/4] KVM: arm64: selftests: Add a test case for KVM_GUESTDBG_SINGLESTEP

2022-09-16 Thread Reiji Watanabe
always reproduce the problem that the previous patch fixes on an Ampere Altra machine. Signed-off-by: Reiji Watanabe --- .../selftests/kvm/aarch64/debug-exceptions.c | 131 ++ 1 file changed, 131 insertions(+) diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b

[PATCH v2 1/4] KVM: arm64: Preserve PSTATE.SS for the guest while single-step is enabled

2022-09-16 Thread Reiji Watanabe
is not used for the next guest entry). With this patch, GET_ONE_REG/SET_ONE_REG will get/set the guest's preserved value, which KVM will preserve and try to restore after single-step is disabled. Fixes: 337b99bf7edf ("KVM: arm64: guest debug, add support for single-step") Signed-off

[PATCH v2 0/4] KVM: arm64: Fix bugs of single-step execution enabled by userspace

2022-09-16 Thread Reiji Watanabe
g" to make DBG_SS_ACTIVE_PENDING and PSTATE.SS consistent [Marc] - Add a fix to preserve PSTATE.SS for the guest. v1: https://lore.kernel.org/all/20220909044636.1997755-1-rei...@google.com/ Reiji Watanabe (4): KVM: arm64: Preserve PSTATE.SS for the guest while single-step is enabled

[PATCH v2 2/4] KVM: arm64: Clear PSTATE.SS when the Software Step state was Active-pending

2022-09-16 Thread Reiji Watanabe
. Fixes: 337b99bf7edf ("KVM: arm64: guest debug, add support for single-step") Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_host.h | 3 +++ arch/arm64/kvm/debug.c| 22 +- arch/arm64/kvm/guest.c| 1 + arch/arm64/kvm/handle_exit.c

[PATCH v2 3/4] KVM: arm64: selftests: Refactor debug-exceptions to make it amenable to new test cases

2022-09-16 Thread Reiji Watanabe
Split up the current test into a helper, but leave the debug version checking in main(), to make it convenient to add a new debug exception test case in a subsequent patch. Signed-off-by: Reiji Watanabe --- .../selftests/kvm/aarch64/debug-exceptions.c | 18 ++ 1 file changed

Re: [RFC PATCH v5 08/38] KVM: arm64: Unlock memslots after stage 2 tables are freed

2022-03-17 Thread Reiji Watanabe
Hi Alex, On 11/17/21 7:38 AM, Alexandru Elisei wrote: Unpin the backing pages mapped at stage 2 after the stage 2 translation tables are destroyed. Signed-off-by: Alexandru Elisei --- arch/arm64/kvm/mmu.c | 23 ++- 1 file changed, 18 insertions(+), 5 deletions(-) diff -

Re: [RFC PATCH 03/25] KVM: arm64: Introduce a validation function for an ID register

2021-10-19 Thread Reiji Watanabe
for the source code comments of arm64_check_features(), which I will fix in v2. On Mon, Oct 18, 2021 at 11:25 PM Andrew Jones wrote: > > On Mon, Oct 18, 2021 at 03:59:35PM -0700, Reiji Watanabe wrote: > > > > > > +int arm64_check_features(u32 sys_reg, u64 val, u64 limit) > >

Re: [RFC PATCH 02/25] KVM: arm64: Save ID registers' sanitized value per vCPU

2021-10-18 Thread Reiji Watanabe
> > > > +static void reset_id_reg(struct kvm_vcpu *vcpu, const struct > > > > sys_reg_desc *rd) > > > > > > Since not all ID registers will use this, then maybe name it > > > reset_sanitised_id_reg? > > > > Thank you for the suggestion. > > > > I named it 'reset_id_reg' according to the naming con

Re: [RFC PATCH 04/25] KVM: arm64: Introduce struct id_reg_info

2021-10-17 Thread Reiji Watanabe
> > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -263,6 +263,76 @@ static bool trap_raz_wi(struct kvm_vcpu *vcpu, > > return read_zero(vcpu, p); > > } > > > > +struct id_reg_info { > > + u32 sys_reg;/* Register ID */ > > + u64 sys

Re: [RFC PATCH 02/25] KVM: arm64: Save ID registers' sanitized value per vCPU

2021-10-16 Thread Reiji Watanabe
On Fri, Oct 15, 2021 at 6:09 AM Andrew Jones wrote: > > On Mon, Oct 11, 2021 at 09:35:12PM -0700, Reiji Watanabe wrote: > > Extend sys_regs[] of kvm_cpu_context for ID registers and save ID > > registers' sanitized value in the array for the vCPU at the first > > v

Re: [RFC PATCH 01/25] KVM: arm64: Add has_reset_once flag for vcpu

2021-10-16 Thread Reiji Watanabe
Hi Andrew, On Fri, Oct 15, 2021 at 3:13 AM Andrew Jones wrote: > > On Mon, Oct 11, 2021 at 09:35:11PM -0700, Reiji Watanabe wrote: > > Introduce 'has_reset_once' flag in kvm_vcpu_arch, which indicates > > if the vCPU reset has been done once, for later use. > >

Re: [PATCH v8 5/8] arm64: cpufeature: Enumerate support for FEAT_ECV >= 0x2

2021-10-13 Thread Reiji Watanabe
ols/cpucaps > +++ b/arch/arm64/tools/cpucaps > @@ -18,6 +18,7 @@ HAS_CRC32 > HAS_DCPODP > HAS_DCPOP > HAS_E0PD > +HAS_ECV2 > HAS_EPAN > HAS_GENERIC_AUTH > HAS_GENERIC_AUTH_ARCH > -- Reviewed-by: Reiji Watanabe Personally, I would prefer a more descriptive name (e.g. ECV_PH

Re: [PATCH v2 03/11] KVM: arm64: Encapsulate reset request logic in a helper function

2021-10-13 Thread Reiji Watanabe
ton wrote: > > > > On Thu, Sep 30, 2021 at 11:05 PM Reiji Watanabe > > > > wrote: > > > > > > > > > > On Thu, Sep 23, 2021 at 12:16 PM Oliver Upton > > > > > wrote: > > > > > > > > > > > >

[RFC PATCH 13/25] KVM: arm64: Make ID registers without id_reg_info writable

2021-10-12 Thread Reiji Watanabe
Make ID registers that don't have id_reg_info writable. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 71cfd62f9c85..2c092136cdff 100644 --- a

[RFC PATCH 18/25] KVM: arm64: Introduce framework to trap disabled features

2021-10-12 Thread Reiji Watanabe
atches will add the feature_config_ctrl for several features. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 117 ++ 1 file changed, 117 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 536e313992d4..55c5

[RFC PATCH 14/25] KVM: arm64: Add consistency checking for frac fields of ID registers

2021-10-12 Thread Reiji Watanabe
: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 98 +-- 1 file changed, 94 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 2c092136cdff..536e313992d4 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm

[RFC PATCH 08/25] KVM: arm64: Make ID_AA64ISAR0_EL1 writable

2021-10-12 Thread Reiji Watanabe
This patch adds id_reg_info for ID_AA64ISAR0_EL1 to make it writable by userspace. Updating sm3, sm4, sha1, sha2 and sha3 fields are allowed only if values of those fields follow Arm ARM. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 31 +++ 1 file

[RFC PATCH 16/25] KVM: arm64: Use vcpu->arch cptr_el2 to track value of cptr_el2 for VHE

2021-10-12 Thread Reiji Watanabe
-off-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_arm.h | 16 arch/arm64/kvm/arm.c | 5 - arch/arm64/kvm/hyp/vhe/switch.c | 14 ++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64

[RFC PATCH 09/25] KVM: arm64: Make ID_AA64ISAR1_EL1 writable

2021-10-12 Thread Reiji Watanabe
This patch adds id_reg_info for ID_AA64ISAR1_EL1 to make it writable by userspace. Return an error if userspace tries to set PTRAUTH related fields of the register to values that conflict with PTRAUTH configuration for the guest (via KVM_ARM_VCPU_INIT). Signed-off-by: Reiji Watanabe --- arch

[RFC PATCH 15/25] KVM: arm64: Introduce KVM_CAP_ARM_ID_REG_WRITABLE capability

2021-10-12 Thread Reiji Watanabe
Introduce a new capability KVM_CAP_ARM_ID_REG_WRITABLE to indicate that ID registers are writable by userspace. Signed-off-by: Reiji Watanabe --- Documentation/virt/kvm/api.rst | 8 arch/arm64/kvm/arm.c | 1 + include/uapi/linux/kvm.h | 1 + 3 files changed, 10

[RFC PATCH 07/25] KVM: arm64: Make ID_AA64PFR1_EL1 writable

2021-10-12 Thread Reiji Watanabe
This patch adds id_reg_info for ID_AA64PFR1_EL1 to make it writable by userspace. Return an error if userspace tries to set MTE field of the register to a value that conflicts with KVM_CAP_ARM_MTE configuration for the guest. Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/sysreg.h

[RFC PATCH 21/25] KVM: arm64: Trap disabled features of ID_AA64DFR0_EL1

2021-10-12 Thread Reiji Watanabe
Add feature_config_ctrl for PMUv3, PMS and TraceFilt, which are indicated in ID_AA64DFR0_EL1, to program configuration registers to trap guest's using those features when they are not exposed to the guest. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c

[RFC PATCH 23/25] KVM: arm64: Trap disabled features of ID_AA64ISAR1_EL1

2021-10-12 Thread Reiji Watanabe
Add feature_config_ctrl for PTRAUTH, which is indicated in ID_AA64ISAR1_EL1, to program configuration register to trap guest's using the feature when it is not exposed to the guest. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 41 +++ 1

[RFC PATCH 25/25] KVM: arm64: selftests: Introduce id_reg_test

2021-10-12 Thread Reiji Watanabe
Introduce a test for aarch64 to validate basic behavior of KVM_GET_ONE_REG and KVM_SET_ONE_REG for ID registers. This test runs only when KVM_CAP_ARM_ID_REG_WRITABLE is supported. Signed-off-by: Reiji Watanabe --- tools/arch/arm64/include/asm/sysreg.h |1 + tools/testing/selftests

[RFC PATCH 10/25] KVM: arm64: Make ID_AA64DFR0_EL1 writable

2021-10-12 Thread Reiji Watanabe
breakpoints according to Arm ARM, return an error if userspace tries to set CTX_CMPS field to such value. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 108 ++ 1 file changed, 97 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b

[RFC PATCH 24/25] KVM: arm64: Activate trapping of disabled CPU features for the guest

2021-10-12 Thread Reiji Watanabe
Call kvm_vcpu_id_regs_trap_activate() at the first KVM_RUN to activate trapping of disabled CPU features. Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/include/asm

[RFC PATCH 19/25] KVM: arm64: Trap disabled features of ID_AA64PFR0_EL1

2021-10-12 Thread Reiji Watanabe
sible), a visibility function for RAS registers is not added. No code is added for AMU's access/visibility handler because the current code already injects the exception for Guest's AMU register access unconditionally because AMU is never exposed to the guest. Signed-off-by: Reiji Watanabe

[RFC PATCH 11/25] KVM: arm64: Make ID_DFR0_EL1 writable

2021-10-12 Thread Reiji Watanabe
This patch adds id_reg_info for ID_DFR0_EL1 to make it writable by userspace. Return an error if userspace tries to set PerfMon field of the register to a value that conflicts with the PMU configuration. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 57

[RFC PATCH 20/25] KVM: arm64: Trap disabled features of ID_AA64PFR1_EL1

2021-10-12 Thread Reiji Watanabe
Add feature_config_ctrl for MTE, which is indicated in ID_AA64PFR1_EL1, to program configuration register to trap the guest's using the feature when it is not exposed to the guest. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 15 +++ 1 file changed, 15 inser

[RFC PATCH 06/25] KVM: arm64: Make ID_AA64PFR0_EL1 writable

2021-10-12 Thread Reiji Watanabe
register to a value that conflicts with SVE configuration for the guest (via KVM_ARM_VCPU_INIT). SIMD/FP/SVE fields of the requested value are validated according to Arm ARM. Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_host.h | 3 - arch/arm64/kvm/arm.c | 18

[RFC PATCH 22/25] KVM: arm64: Trap disabled features of ID_AA64MMFR1_EL1

2021-10-12 Thread Reiji Watanabe
ailability. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 23a3bcac4986..68df4e4eba05 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch

[RFC PATCH 04/25] KVM: arm64: Introduce struct id_reg_info

2021-10-12 Thread Reiji Watanabe
. No ID register has the structure yet and the following patches will add the id_reg_info for some ID registers. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 120 +++--- 1 file changed, 111 insertions(+), 9 deletions(-) diff --git a/arch/arm6

[RFC PATCH 17/25] KVM: arm64: Use vcpu->arch.mdcr_el2 to track value of mdcr_el2

2021-10-12 Thread Reiji Watanabe
: Reiji Watanabe --- arch/arm64/include/asm/kvm_arm.h | 16 arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/debug.c | 13 - 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm

[RFC PATCH 05/25] KVM: arm64: Keep consistency of ID registers between vCPUs

2021-10-12 Thread Reiji Watanabe
value of ID register for a vCPU that already started KVM_RUN once. Changing ID register is still not allowed at present though. Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/arm.c | 3 +++ arch/arm64/kvm/sys_regs.c | 31

[RFC PATCH 12/25] KVM: arm64: Make MVFR1_EL1 writable

2021-10-12 Thread Reiji Watanabe
valid combinations. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 84c064dfc63a..71cfd62f9c85 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b

[RFC PATCH 00/25] KVM: arm64: Make CPU ID registers writable by userspace

2021-10-12 Thread Reiji Watanabe
ttps://lore.kernel.org/kvm/20201102033422.657391-1-liangpen...@huawei.com/ [3] https://lore.kernel.org/kvmarm/20211007233439.1826892-1-rana...@google.com/ Reiji Watanabe (25): KVM: arm64: Add has_reset_once flag for vcpu KVM: arm64: Save ID registers' sanitized value per vCPU KVM: arm64:

[RFC PATCH 02/25] KVM: arm64: Save ID registers' sanitized value per vCPU

2021-10-12 Thread Reiji Watanabe
Extend sys_regs[] of kvm_cpu_context for ID registers and save ID registers' sanitized value in the array for the vCPU at the first vCPU reset. Use the saved ones when ID registers are read by userspace (via KVM_GET_ONE_REG) or the guest. Signed-off-by: Reiji Watanabe --- arch/arm64/includ

[RFC PATCH 03/25] KVM: arm64: Introduce a validation function for an ID register

2021-10-12 Thread Reiji Watanabe
n the host. Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/kernel/cpufeature.c | 26 ++ 2 files changed, 27 insertions(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index ef6be92

[RFC PATCH 01/25] KVM: arm64: Add has_reset_once flag for vcpu

2021-10-12 Thread Reiji Watanabe
Introduce 'has_reset_once' flag in kvm_vcpu_arch, which indicates if the vCPU reset has been done once, for later use. Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/reset.c| 4 2 files changed, 6 insertions(+) diff --

Re: [PATCH v2 03/11] KVM: arm64: Encapsulate reset request logic in a helper function

2021-10-01 Thread Reiji Watanabe
; -*/ > - smp_wmb(); > - > - vcpu->arch.power_off = false; > + kvm_psci_vcpu_request_reset(vcpu, smccc_get_arg2(source_vcpu), > + smccc_get_arg3(source_vcpu), > + kvm_vcpu_is_be(sou

Re: [PATCH v2 02/11] KVM: arm64: Clean up SMC64 PSCI filtering for AArch32 guests

2021-10-01 Thread Reiji Watanabe
ons. > > Signed-off-by: Oliver Upton Looks nice. Reviewed-by: Reiji Watanabe ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v2 01/11] KVM: arm64: Drop unused vcpu param to kvm_psci_valid_affinity()

2021-10-01 Thread Reiji Watanabe
On Thu, Sep 23, 2021 at 12:16 PM Oliver Upton wrote: > > The helper function does not need a pointer to the vCPU, as it only > consults a constant mask; drop the unused vcpu parameter. > > Signed-off-by: Oliver Upton Reviewed-by:

Re: [PATCH v8 6/8] KVM: arm64: Allow userspace to configure a guest's counter-timer offset

2021-09-24 Thread Reiji Watanabe
Hi Oliver, I have additional questions/comments. > > +2.2. ATTRIBUTE: KVM_ARM_VCPU_TIMER_PHYS_OFFSET > > +- > > + > > +:Parameters: in kvm_device_attr.addr the address for the timer offset is a > > + pointer to a __u64 > > + > > +Returns: > > +

Re: [PATCH v8 6/8] KVM: arm64: Allow userspace to configure a guest's counter-timer offset

2021-09-22 Thread Reiji Watanabe
Hi Oliver, On Thu, Sep 16, 2021 at 11:15 AM Oliver Upton wrote: > > Presently, KVM provides no facilities for correctly migrating a guest > that depends on the physical counter-timer. While most guests (barring > NV, of course) should not depend on the physical counter-timer, an > operator may wi

Re: [PATCH v8 2/8] KVM: arm64: Separate guest/host counter offset values

2021-09-22 Thread Reiji Watanabe
u32 host_timer_irq; > u32 host_timer_irq_flags; > + > + /* offset relative to the host's physical counter-timer */ > + u64 host_offset; > }; Just out of curiosity, have you c

Re: [PATCH v6 09/14] KVM: arm64: selftests: Add guest support to get the vcpuid

2021-09-14 Thread Reiji Watanabe
of the calling vcpu. The interface is architecture > independent, but defined only for arm64 as of now. > > Suggested-by: Reiji Watanabe > Signed-off-by: Raghavendra Rao Ananta > Reviewed-by: Ricardo Koller Reviewed-by: Reiji Watanabe Thank yo

Re: [PATCH v4 09/18] KVM: arm64: selftests: Add guest support to get the vcpuid

2021-09-12 Thread Reiji Watanabe
Hi Raghu and all, On Wed, Sep 8, 2021 at 6:38 PM Raghavendra Rao Ananta wrote: > > At times, such as when in the interrupt handler, the guest wants > to get the vcpuid that it's running on. As a result, introduce > get_vcpuid() that returns the vcpuid of the calling vcpu. At its > backend, the VM