Override read values from feature ID registers to reflect Hafnium support
Hafnium limits access to certain features to certain or to all VMs. When
querying available features in feature ID registers, the returned result should
reflect the supported features.
Reorganize how features are trapped so that the logic can be controlled in one
place rather than being spread out throughout the code.
Bug: 144415253
Bug: 144898870
Change-Id: Id13fdcd3fd50beb70bbd51a3de15e2c5e1003eb6
diff --git a/src/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index 0e75b97..a2c4bf4 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -31,6 +31,7 @@
#include "vmapi/hf/call.h"
#include "debug_el1.h"
+#include "feature_id.h"
#include "msr.h"
#include "perfmon.h"
#include "psci.h"
@@ -144,8 +145,8 @@
/*
* Ensure that no data reads or writes for the VM happen until after the
- * TLB invalidation has taken effect. Non-sharable is enough because the
- * TLB is local to the CPU.
+ * TLB invalidation has taken effect. Non-shareable is enough because
+ * the TLB is local to the CPU.
*/
dsb(nsh);
}
@@ -753,6 +754,10 @@
if (!perfmon_process_access(vcpu, vm_id, esr_el2)) {
return inject_el1_unknown_exception(vcpu, esr_el2);
}
+ } else if (feature_id_is_register_access(esr_el2)) {
+ if (!feature_id_process_access(vcpu, esr_el2)) {
+ return inject_el1_unknown_exception(vcpu, esr_el2);
+ }
} else {
return inject_el1_unknown_exception(vcpu, esr_el2);
}