Commit 272a067d authored by Raghavendra Rao Ananta's avatar Raghavendra Rao Ananta Committed by Marc Zyngier

tools: arm64: Import sysreg.h

Bring-in the kernel's arch/arm64/include/asm/sysreg.h
into tools/ for arm64 to make use of all the standard
register definitions in consistence with the kernel.

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.
Reviewed-by: default avatarAndrew Jones <drjones@redhat.com>
Reviewed-by: default avatarOliver Upton <oupton@google.com>
Signed-off-by: default avatarRaghavendra Rao Ananta <rananta@google.com>
[maz: squashed two commits in order to keep the series bisectable]
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211007233439.1826892-3-rananta@google.com
Link: https://lore.kernel.org/r/20211007233439.1826892-4-rananta@google.com
parent 88ec7e25
This diff is collapsed.
...@@ -34,16 +34,16 @@ static void reset_debug_state(void) ...@@ -34,16 +34,16 @@ static void reset_debug_state(void)
{ {
asm volatile("msr daifset, #8"); asm volatile("msr daifset, #8");
write_sysreg(osdlr_el1, 0); write_sysreg(0, osdlr_el1);
write_sysreg(oslar_el1, 0); write_sysreg(0, oslar_el1);
isb(); isb();
write_sysreg(mdscr_el1, 0); write_sysreg(0, mdscr_el1);
/* This test only uses the first bp and wp slot. */ /* This test only uses the first bp and wp slot. */
write_sysreg(dbgbvr0_el1, 0); write_sysreg(0, dbgbvr0_el1);
write_sysreg(dbgbcr0_el1, 0); write_sysreg(0, dbgbcr0_el1);
write_sysreg(dbgwcr0_el1, 0); write_sysreg(0, dbgwcr0_el1);
write_sysreg(dbgwvr0_el1, 0); write_sysreg(0, dbgwvr0_el1);
isb(); isb();
} }
...@@ -53,14 +53,14 @@ static void install_wp(uint64_t addr) ...@@ -53,14 +53,14 @@ static void install_wp(uint64_t addr)
uint32_t mdscr; uint32_t mdscr;
wcr = DBGWCR_LEN8 | DBGWCR_RD | DBGWCR_WR | DBGWCR_EL1 | DBGWCR_E; wcr = DBGWCR_LEN8 | DBGWCR_RD | DBGWCR_WR | DBGWCR_EL1 | DBGWCR_E;
write_sysreg(dbgwcr0_el1, wcr); write_sysreg(wcr, dbgwcr0_el1);
write_sysreg(dbgwvr0_el1, addr); write_sysreg(addr, dbgwvr0_el1);
isb(); isb();
asm volatile("msr daifclr, #8"); asm volatile("msr daifclr, #8");
mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE;
write_sysreg(mdscr_el1, mdscr); write_sysreg(mdscr, mdscr_el1);
isb(); isb();
} }
...@@ -70,14 +70,14 @@ static void install_hw_bp(uint64_t addr) ...@@ -70,14 +70,14 @@ static void install_hw_bp(uint64_t addr)
uint32_t mdscr; uint32_t mdscr;
bcr = DBGBCR_LEN8 | DBGBCR_EXEC | DBGBCR_EL1 | DBGBCR_E; bcr = DBGBCR_LEN8 | DBGBCR_EXEC | DBGBCR_EL1 | DBGBCR_E;
write_sysreg(dbgbcr0_el1, bcr); write_sysreg(bcr, dbgbcr0_el1);
write_sysreg(dbgbvr0_el1, addr); write_sysreg(addr, dbgbvr0_el1);
isb(); isb();
asm volatile("msr daifclr, #8"); asm volatile("msr daifclr, #8");
mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE;
write_sysreg(mdscr_el1, mdscr); write_sysreg(mdscr, mdscr_el1);
isb(); isb();
} }
...@@ -88,7 +88,7 @@ static void install_ss(void) ...@@ -88,7 +88,7 @@ static void install_ss(void)
asm volatile("msr daifclr, #8"); asm volatile("msr daifclr, #8");
mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_SS; mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_SS;
write_sysreg(mdscr_el1, mdscr); write_sysreg(mdscr, mdscr_el1);
isb(); isb();
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "kvm_util.h" #include "kvm_util.h"
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/types.h> #include <linux/types.h>
#include <asm/sysreg.h>
#define ARM64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ #define ARM64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
...@@ -119,18 +120,6 @@ void vm_install_exception_handler(struct kvm_vm *vm, ...@@ -119,18 +120,6 @@ void vm_install_exception_handler(struct kvm_vm *vm,
void vm_install_sync_handler(struct kvm_vm *vm, void vm_install_sync_handler(struct kvm_vm *vm,
int vector, int ec, handler_fn handler); 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 isb() asm volatile("isb" : : : "memory")
#define dsb(opt) asm volatile("dsb " #opt : : : "memory") #define dsb(opt) asm volatile("dsb " #opt : : : "memory")
#define dmb(opt) asm volatile("dmb " #opt : : : "memory") #define dmb(opt) asm volatile("dmb " #opt : : : "memory")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment