Message ID | 20210909013818.1191270-4-rananta@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: arm64: selftests: Introduce arch_timer selftest | expand |
On Thu, Sep 09, 2021 at 01:38:03AM +0000, Raghavendra Rao Ananta wrote: > Make use of the register read/write definitions from > sysreg.h, instead of the existing definitions. A syntax > correction is needed for the files that use write_sysreg() > to make it compliant with the new (kernel's) syntax. > > Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> > --- > .../selftests/kvm/aarch64/debug-exceptions.c | 28 +++++++++---------- > .../selftests/kvm/include/aarch64/processor.h | 13 +-------- > 2 files changed, 15 insertions(+), 26 deletions(-) > [...] > diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h > index 96578bd46a85..bed4ffa70905 100644 > --- a/tools/testing/selftests/kvm/include/aarch64/processor.h > +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h > @@ -8,6 +8,7 @@ > #define SELFTEST_KVM_PROCESSOR_H > > #include "kvm_util.h" > +#include "sysreg.h" #include <asm/sysreg.h>, based on comments to 02/18 Otherwise: Reviewed-by: Oliver Upton <oupton@google.com>
On Thu, Sep 09, 2021 at 01:38:03AM +0000, Raghavendra Rao Ananta wrote: > Make use of the register read/write definitions from > sysreg.h, instead of the existing definitions. A syntax > correction is needed for the files that use write_sysreg() > to make it compliant with the new (kernel's) syntax. > > Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> > --- > .../selftests/kvm/aarch64/debug-exceptions.c | 28 +++++++++---------- > .../selftests/kvm/include/aarch64/processor.h | 13 +-------- > 2 files changed, 15 insertions(+), 26 deletions(-) > Same comment as Oliver, otherwise Reviewed-by: Andrew Jones <drjones@redhat.com>
On Wed, Sep 8, 2021 at 11:56 PM Andrew Jones <drjones@redhat.com> wrote: > > On Thu, Sep 09, 2021 at 01:38:03AM +0000, Raghavendra Rao Ananta wrote: > > Make use of the register read/write definitions from > > sysreg.h, instead of the existing definitions. A syntax > > correction is needed for the files that use write_sysreg() > > to make it compliant with the new (kernel's) syntax. > > > > Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> > > --- > > .../selftests/kvm/aarch64/debug-exceptions.c | 28 +++++++++---------- > > .../selftests/kvm/include/aarch64/processor.h | 13 +-------- > > 2 files changed, 15 insertions(+), 26 deletions(-) > > > > Same comment as Oliver, otherwise > Will fix. Regards, Raghavendra > Reviewed-by: Andrew Jones <drjones@redhat.com> >
diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c index e5e6c92b60da..11fd23e21cb4 100644 --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c @@ -34,16 +34,16 @@ static void reset_debug_state(void) { asm volatile("msr daifset, #8"); - write_sysreg(osdlr_el1, 0); - write_sysreg(oslar_el1, 0); + write_sysreg(0, osdlr_el1); + write_sysreg(0, oslar_el1); isb(); - write_sysreg(mdscr_el1, 0); + write_sysreg(0, mdscr_el1); /* This test only uses the first bp and wp slot. */ - write_sysreg(dbgbvr0_el1, 0); - write_sysreg(dbgbcr0_el1, 0); - write_sysreg(dbgwcr0_el1, 0); - write_sysreg(dbgwvr0_el1, 0); + write_sysreg(0, dbgbvr0_el1); + write_sysreg(0, dbgbcr0_el1); + write_sysreg(0, dbgwcr0_el1); + write_sysreg(0, dbgwvr0_el1); isb(); } @@ -53,14 +53,14 @@ static void install_wp(uint64_t addr) uint32_t mdscr; wcr = DBGWCR_LEN8 | DBGWCR_RD | DBGWCR_WR | DBGWCR_EL1 | DBGWCR_E; - write_sysreg(dbgwcr0_el1, wcr); - write_sysreg(dbgwvr0_el1, addr); + write_sysreg(wcr, dbgwcr0_el1); + write_sysreg(addr, dbgwvr0_el1); isb(); asm volatile("msr daifclr, #8"); mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr_el1, mdscr); + write_sysreg(mdscr, mdscr_el1); isb(); } @@ -70,14 +70,14 @@ static void install_hw_bp(uint64_t addr) uint32_t mdscr; bcr = DBGBCR_LEN8 | DBGBCR_EXEC | DBGBCR_EL1 | DBGBCR_E; - write_sysreg(dbgbcr0_el1, bcr); - write_sysreg(dbgbvr0_el1, addr); + write_sysreg(bcr, dbgbcr0_el1); + write_sysreg(addr, dbgbvr0_el1); isb(); asm volatile("msr daifclr, #8"); mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr_el1, mdscr); + write_sysreg(mdscr, mdscr_el1); isb(); } @@ -88,7 +88,7 @@ static void install_ss(void) asm volatile("msr daifclr, #8"); mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_SS; - write_sysreg(mdscr_el1, mdscr); + write_sysreg(mdscr, mdscr_el1); isb(); } diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h index 96578bd46a85..bed4ffa70905 100644 --- a/tools/testing/selftests/kvm/include/aarch64/processor.h +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h @@ -8,6 +8,7 @@ #define SELFTEST_KVM_PROCESSOR_H #include "kvm_util.h" +#include "sysreg.h" #include <linux/stringify.h> #include <linux/types.h> @@ -119,18 +120,6 @@ void vm_install_exception_handler(struct kvm_vm *vm, void vm_install_sync_handler(struct kvm_vm *vm, int vector, int ec, handler_fn handler); -#define write_sysreg(reg, val) \ -({ \ - u64 __val = (u64)(val); \ - asm volatile("msr " __stringify(reg) ", %x0" : : "rZ" (__val)); \ -}) - -#define read_sysreg(reg) \ -({ u64 val; \ - asm volatile("mrs %0, "__stringify(reg) : "=r"(val) : : "memory");\ - val; \ -}) - #define isb() asm volatile("isb" : : : "memory") #define dsb(opt) asm volatile("dsb " #opt : : : "memory") #define dmb(opt) asm volatile("dmb " #opt : : : "memory")
Make use of the register read/write definitions from sysreg.h, instead of the existing definitions. A syntax correction is needed for the files that use write_sysreg() to make it compliant with the new (kernel's) syntax. Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> --- .../selftests/kvm/aarch64/debug-exceptions.c | 28 +++++++++---------- .../selftests/kvm/include/aarch64/processor.h | 13 +-------- 2 files changed, 15 insertions(+), 26 deletions(-)