Not emulated registers on BOOKE_HV (GS-mode)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex,

There is below comment in arch/powerpc/kvm/booke_emulate.c

/*
 * NOTE: some of these registers are not emulated on BOOKE_HV (GS-mode).
 * Their backing store is in real registers, and these functions
 * will return the wrong result if called for them in another context
 * (such as debugging).
 */

"some of these registers are not emulated on BOOKE_HV (GS-mode)" 
 1) Is not that mtspr()/mfspr() for "not emulated" registers should follow EMULATE_FAIL path? So should be ifdef out for BOOKE_HV? Otherwise the emulation code execute.
 2) Or These are not emulated because the GS mode have direct access to these registers, Right? So no trap?


"and these functions will return the wrong result if called for them in another context (such as debugging)."
 1) So do you mean that guest is not supposed to access these registers in normal scenario but the debugger (some command on gdb in guest) can access these register? then does it make sense to treat mtspr() as nop and mfspr returns 0/undefined?

In our local repository Scott Wood removed this comment by ifdef out those registers for BOOKE_HV.
Below is the change (extracted - not the exact patch which does this)

diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 83c3796..6d78906 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -46,18 +46,21 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
        switch (get_op(inst)) {
        case 19:
                switch (get_xop(inst)) {
+#ifndef CONFIG_KVM_BOOKE_HV
                case OP_19_XOP_RFI:
                        kvmppc_emul_rfi(vcpu);
                        kvmppc_set_exit_type(vcpu, EMULATED_RFI_EXITS);
                        *advance = 0;
                        break;

+#endif
                default:
                        emulated = EMULATE_FAIL;
                        break;
                }
                break;

+#ifndef CONFIG_KVM_BOOKE_HV
        case 31:
                switch (get_xop(inst)) {

@@ -89,6 +92,7 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,

                break;

+#endif
        default:
                emulated = EMULATE_FAIL;
        }
@@ -96,23 +100,19 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
        return emulated;
 }

-/*
- * NOTE: some of these registers are not emulated on BOOKE_HV (GS-mode).
- * Their backing store is in real registers, and these functions
- * will return the wrong result if called for them in another context
- * (such as debugging).
- */
 int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
 {
        int emulated = EMULATE_DONE;

        switch (sprn) {
+#ifndef CONFIG_KVM_BOOKE_HV
        case SPRN_DEAR:
                vcpu->arch.shared->dar = spr_val;
                break;
        case SPRN_ESR:
                vcpu->arch.shared->esr = spr_val;
                break;
+#endif
        case SPRN_DBCR0:
                vcpu->arch.dbcr0 = spr_val;
                break;
@@ -223,6 +223,7 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
        int emulated = EMULATE_DONE;

        switch (sprn) {
+#ifndef CONFIG_KVM_BOOKE_HV
        case SPRN_IVPR:
                *spr_val = vcpu->arch.ivpr;
                break;
@@ -232,6 +233,7 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
        case SPRN_ESR:
                *spr_val = vcpu->arch.shared->esr;
                break;
+#endif
        case SPRN_DBCR0:
                *spr_val = vcpu->arch.dbcr0;
                break;
-- 
1.7.0.4


Thanks
-Bharat

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM Development]     [KVM ARM]     [KVM ia64]     [Linux Virtualization]     [Linux USB Devel]     [Linux Video]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux