Skip to content

Commit

Permalink
[AArch64] Query and JSON export Hypervisor Configuration Register
Browse files Browse the repository at this point in the history
* `HCR_EL2` succesfully accessed in `EL1` with RK3588 (A55 + A76)
* Experimental mode required
  • Loading branch information
cyring committed Nov 18, 2024
1 parent 09a1d36 commit ed5feaa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions aarch64/corefreq-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ typedef struct

struct {
Bit64 FLAGS __attribute__ ((aligned (8)));
Bit64 HCR __attribute__ ((aligned (8)));
Bit64 SCTLR __attribute__ ((aligned (8)));
Bit64 SCTLR2 __attribute__ ((aligned (8)));
Bit64 EL __attribute__ ((aligned (8)));
Expand Down
4 changes: 4 additions & 0 deletions aarch64/corefreq-cli-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,10 @@ void JsonSysInfo(RO(SHM_STRUCT) *RO(Shm))
json_key(&s, "FLAGS");
json_string(&s, hexStr);

snprintf(hexStr, 32, "0x%llx", RO(Shm)->Cpu[cpu].SystemRegister.HCR);
json_key(&s, "HCR");
json_string(&s, hexStr);

snprintf(hexStr, 32, "0x%llx", RO(Shm)->Cpu[cpu].SystemRegister.SCTLR);
json_key(&s, "SCTLR");
json_string(&s, hexStr);
Expand Down
1 change: 1 addition & 0 deletions aarch64/corefreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ typedef struct

struct {
Bit64 FLAGS __attribute__ ((aligned (8)));
Bit64 HCR __attribute__ ((aligned (8)));
Bit64 SCTLR __attribute__ ((aligned (8)));
Bit64 SCTLR2 __attribute__ ((aligned (8)));
Bit64 EL __attribute__ ((aligned (8)));
Expand Down
3 changes: 3 additions & 0 deletions aarch64/corefreqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,9 @@ void SystemRegisters( RO(SHM_STRUCT) *RO(Shm), RO(CORE) **RO(Core),
RO(Shm)->Cpu[cpu].SystemRegister.FLAGS = \
RO(Core, AT(cpu))->SystemRegister.FLAGS;

RO(Shm)->Cpu[cpu].SystemRegister.HCR = \
RO(Core, AT(cpu))->SystemRegister.HCR;

RO(Shm)->Cpu[cpu].SystemRegister.SCTLR = \
RO(Core, AT(cpu))->SystemRegister.SCTLR;

Expand Down
8 changes: 8 additions & 0 deletions aarch64/corefreqk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,14 @@ static void SystemRegisters(CORE_RO *Core)

isar2.value = SysRegRead(ID_AA64ISAR2_EL1);

if (Experimental) {
__asm__ __volatile__(
"mrs %[hcr] , hcr_el2"
: [hcr] "=r" (Core->SystemRegister.HCR)
:
: "cc", "memory"
);
}
__asm__ __volatile__(
"mrs %[sctlr], sctlr_el1" "\n\t"
"mrs %[mmfr1], id_aa64mmfr1_el1""\n\t"
Expand Down

0 comments on commit ed5feaa

Please sign in to comment.