Skip to content

Commit

Permalink
x86: Remove guest registers and cpu_data parameters from apic_mmio_ac…
Browse files Browse the repository at this point in the history
…cess

The function only works on the current CPU, thus should avoid to take
misleading parameters. The necessary references can be obtained inline.

With the parameters no longer needed, the callers
svm/vmx_handle_apic_access can drop some of them as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
jan-kiszka committed Apr 10, 2015
1 parent bb784c9 commit 015f5e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
9 changes: 4 additions & 5 deletions hypervisor/arch/x86/apic.c
Expand Up @@ -468,8 +468,7 @@ static bool apic_invalid_lvt_delivery_mode(unsigned int reg, u32 val)
return true;
}

unsigned int apic_mmio_access(union registers *guest_regs,
struct per_cpu *cpu_data, unsigned long rip,
unsigned int apic_mmio_access(unsigned long rip,
const struct guest_paging_structures *pg_structs,
unsigned int reg, bool is_write)
{
Expand All @@ -485,7 +484,7 @@ unsigned int apic_mmio_access(union registers *guest_regs,
return 0;
}
if (is_write) {
val = guest_regs->by_index[inst.reg_num];
val = this_cpu_data()->guest_regs.by_index[inst.reg_num];
if (apic_accessing_reserved_bits(reg, val))
return 0;

Expand All @@ -494,7 +493,7 @@ unsigned int apic_mmio_access(union registers *guest_regs,
apic_ops.read(APIC_REG_ICR_HI)))
return 0;
} else if (reg == APIC_REG_LDR &&
val != 1UL << (cpu_data->cpu_id + XAPIC_DEST_SHIFT)) {
val != 1UL << (this_cpu_id() + XAPIC_DEST_SHIFT)) {
panic_printk("FATAL: Unsupported change to LDR: %x\n",
val);
return 0;
Expand All @@ -512,7 +511,7 @@ unsigned int apic_mmio_access(union registers *guest_regs,
apic_ops.write(reg, val);
} else {
val = apic_ops.read(reg);
guest_regs->by_index[inst.reg_num] = val;
this_cpu_data()->guest_regs.by_index[inst.reg_num] = val;
}
return inst.inst_len;
}
Expand Down
3 changes: 1 addition & 2 deletions hypervisor/arch/x86/include/asm/apic.h
Expand Up @@ -161,8 +161,7 @@ void apic_send_irq(struct apic_irq_message irq_msg);

void apic_irq_handler(void);

unsigned int apic_mmio_access(union registers *guest_regs,
struct per_cpu *cpu_data, unsigned long rip,
unsigned int apic_mmio_access(unsigned long rip,
const struct guest_paging_structures *pg_structs,
unsigned int reg, bool is_write);

Expand Down
9 changes: 4 additions & 5 deletions hypervisor/arch/x86/svm.c
Expand Up @@ -845,8 +845,7 @@ static bool svm_handle_msr_write(union registers *guest_regs,
* TODO: This handles unaccelerated (non-AVIC) access. AVIC should
* be treated separately in svm_handle_avic_access().
*/
static bool svm_handle_apic_access(union registers *guest_regs,
struct per_cpu *cpu_data)
static bool svm_handle_apic_access(struct per_cpu *cpu_data)
{
struct vmcb *vmcb = &cpu_data->vmcb;
struct guest_paging_structures pg_structs;
Expand All @@ -863,8 +862,8 @@ static bool svm_handle_apic_access(union registers *guest_regs,
if (!vcpu_get_guest_paging_structs(&pg_structs))
goto out_err;

inst_len = apic_mmio_access(guest_regs, cpu_data, vmcb->rip,
&pg_structs, offset >> 4, is_write);
inst_len = apic_mmio_access(vmcb->rip, &pg_structs, offset >> 4,
is_write);
if (!inst_len)
goto out_err;

Expand Down Expand Up @@ -975,7 +974,7 @@ void vcpu_handle_exit(struct per_cpu *cpu_data)
vmcb->exitinfo2 < XAPIC_BASE + PAGE_SIZE) {
/* APIC access in non-AVIC mode */
cpu_data->stats[JAILHOUSE_CPU_STAT_VMEXITS_XAPIC]++;
if (svm_handle_apic_access(guest_regs, cpu_data))
if (svm_handle_apic_access(cpu_data))
return;
} else {
/* General MMIO (IOAPIC, PCI etc) */
Expand Down
8 changes: 3 additions & 5 deletions hypervisor/arch/x86/vmx.c
Expand Up @@ -948,8 +948,7 @@ void vcpu_vendor_set_guest_pat(unsigned long val)
vmcs_write64(GUEST_IA32_PAT, val);
}

static bool vmx_handle_apic_access(union registers *guest_regs,
struct per_cpu *cpu_data)
static bool vmx_handle_apic_access(void)
{
struct guest_paging_structures pg_structs;
unsigned int inst_len, offset;
Expand All @@ -969,8 +968,7 @@ static bool vmx_handle_apic_access(union registers *guest_regs,
if (!vcpu_get_guest_paging_structs(&pg_structs))
break;

inst_len = apic_mmio_access(guest_regs, cpu_data,
vmcs_read64(GUEST_RIP),
inst_len = apic_mmio_access(vmcs_read64(GUEST_RIP),
&pg_structs, offset >> 4,
is_write);
if (!inst_len)
Expand Down Expand Up @@ -1094,7 +1092,7 @@ void vcpu_handle_exit(struct per_cpu *cpu_data)
break;
case EXIT_REASON_APIC_ACCESS:
cpu_data->stats[JAILHOUSE_CPU_STAT_VMEXITS_XAPIC]++;
if (vmx_handle_apic_access(guest_regs, cpu_data))
if (vmx_handle_apic_access())
return;
break;
case EXIT_REASON_XSETBV:
Expand Down

0 comments on commit 015f5e5

Please sign in to comment.