Message ID | 20220825050846.3418868-5-reijiw@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: arm64: selftests: Test linked {break,watch}points | expand |
On Wed, Aug 24, 2022 at 10:08:41PM -0700, Reiji Watanabe wrote: > Add helpers to enable breakpoint and watchpoint exceptions. > > Signed-off-by: Reiji Watanabe <reijiw@google.com> > --- > .../selftests/kvm/aarch64/debug-exceptions.c | 25 ++++++++++--------- > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > index 183ee16acb7d..713c7240b680 100644 > --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > @@ -128,10 +128,20 @@ static void enable_os_lock(void) > GUEST_ASSERT(read_sysreg(oslsr_el1) & 2); > } > > +static void enable_debug_bwp_exception(void) uber-nit: enable_monitor_debug_exceptions() (more closely matches the definition of MDSCR_EL1.MDE) With that: Reviewed-by: Oliver Upton <oliver.upton@linux.dev> -- Thanks, Oliver
Hi Oliver, On Thu, Aug 25, 2022 at 10:22 AM Oliver Upton <oliver.upton@linux.dev> wrote: > > On Wed, Aug 24, 2022 at 10:08:41PM -0700, Reiji Watanabe wrote: > > Add helpers to enable breakpoint and watchpoint exceptions. > > > > Signed-off-by: Reiji Watanabe <reijiw@google.com> > > --- > > .../selftests/kvm/aarch64/debug-exceptions.c | 25 ++++++++++--------- > > 1 file changed, 13 insertions(+), 12 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > > index 183ee16acb7d..713c7240b680 100644 > > --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > > +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > > @@ -128,10 +128,20 @@ static void enable_os_lock(void) > > GUEST_ASSERT(read_sysreg(oslsr_el1) & 2); > > } > > > > +static void enable_debug_bwp_exception(void) > > uber-nit: enable_monitor_debug_exceptions() > > (more closely matches the definition of MDSCR_EL1.MDE) Thank you for the proposal. Sounds better! > With that: > > Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Thank you for the review! Reiji
On Thu, Aug 25, 2022 at 10:21:49AM -0700, Oliver Upton wrote: > On Wed, Aug 24, 2022 at 10:08:41PM -0700, Reiji Watanabe wrote: > > Add helpers to enable breakpoint and watchpoint exceptions. > > > > Signed-off-by: Reiji Watanabe <reijiw@google.com> > > --- > > .../selftests/kvm/aarch64/debug-exceptions.c | 25 ++++++++++--------- > > 1 file changed, 13 insertions(+), 12 deletions(-) > > > > diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > > index 183ee16acb7d..713c7240b680 100644 > > --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > > +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > > @@ -128,10 +128,20 @@ static void enable_os_lock(void) > > GUEST_ASSERT(read_sysreg(oslsr_el1) & 2); > > } > > > > +static void enable_debug_bwp_exception(void) > > uber-nit: enable_monitor_debug_exceptions() > > (more closely matches the definition of MDSCR_EL1.MDE) oh, didn't know the MDE was for monitor debug exc. Anyway: Reviewed-by: Ricardo Koller <ricarkol@google.com> > > With that: > > Reviewed-by: Oliver Upton <oliver.upton@linux.dev> > > -- > Thanks, > Oliver > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c index 183ee16acb7d..713c7240b680 100644 --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c @@ -128,10 +128,20 @@ static void enable_os_lock(void) GUEST_ASSERT(read_sysreg(oslsr_el1) & 2); } +static void enable_debug_bwp_exception(void) +{ + uint32_t mdscr; + + asm volatile("msr daifclr, #8"); + + mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; + write_sysreg(mdscr, mdscr_el1); + isb(); +} + static void install_wp(uint8_t wpn, uint64_t addr) { uint32_t wcr; - uint32_t mdscr; wcr = DBGWCR_LEN8 | DBGWCR_RD | DBGWCR_WR | DBGWCR_EL1 | DBGWCR_E; write_dbgwcr(wpn, wcr); @@ -139,28 +149,19 @@ static void install_wp(uint8_t wpn, uint64_t addr) isb(); - asm volatile("msr daifclr, #8"); - - mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr, mdscr_el1); - isb(); + enable_debug_bwp_exception(); } static void install_hw_bp(uint8_t bpn, uint64_t addr) { uint32_t bcr; - uint32_t mdscr; bcr = DBGBCR_LEN8 | DBGBCR_EXEC | DBGBCR_EL1 | DBGBCR_E; write_dbgbcr(bpn, bcr); write_dbgbvr(bpn, addr); isb(); - asm volatile("msr daifclr, #8"); - - mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr, mdscr_el1); - isb(); + enable_debug_bwp_exception(); } static void install_ss(void)
Add helpers to enable breakpoint and watchpoint exceptions. Signed-off-by: Reiji Watanabe <reijiw@google.com> --- .../selftests/kvm/aarch64/debug-exceptions.c | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-)