mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 18:23:57 -06:00
i386/tcg: implement x2APIC registers MSR access
This commit creates apic_register_read/write which are used by both apic_mem_read/write for MMIO access and apic_msr_read/write for MSR access. The apic_msr_read/write returns -1 on error, accelerator can use this to raise the appropriate exception. Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com> Message-Id: <20240111154404.5333-2-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
bad38726e9
commit
b2101358e5
5 changed files with 127 additions and 32 deletions
|
@ -545,6 +545,9 @@ typedef enum X86Seg {
|
|||
#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490
|
||||
#define MSR_IA32_VMX_VMFUNC 0x00000491
|
||||
|
||||
#define MSR_APIC_START 0x00000800
|
||||
#define MSR_APIC_END 0x000008ff
|
||||
|
||||
#define XSTATE_FP_BIT 0
|
||||
#define XSTATE_SSE_BIT 1
|
||||
#define XSTATE_YMM_BIT 2
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "exec/address-spaces.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/helper-tcg.h"
|
||||
#include "hw/i386/apic.h"
|
||||
|
||||
void helper_outb(CPUX86State *env, uint32_t port, uint32_t data)
|
||||
{
|
||||
|
@ -289,6 +290,19 @@ void helper_wrmsr(CPUX86State *env)
|
|||
env->msr_bndcfgs = val;
|
||||
cpu_sync_bndcs_hflags(env);
|
||||
break;
|
||||
case MSR_APIC_START ... MSR_APIC_END: {
|
||||
int ret;
|
||||
int index = (uint32_t)env->regs[R_ECX] - MSR_APIC_START;
|
||||
|
||||
bql_lock();
|
||||
ret = apic_msr_write(index, val);
|
||||
bql_unlock();
|
||||
if (ret < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL
|
||||
&& (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL +
|
||||
|
@ -455,6 +469,19 @@ void helper_rdmsr(CPUX86State *env)
|
|||
val = (cs->nr_threads * cs->nr_cores) | (cs->nr_cores << 16);
|
||||
break;
|
||||
}
|
||||
case MSR_APIC_START ... MSR_APIC_END: {
|
||||
int ret;
|
||||
int index = (uint32_t)env->regs[R_ECX] - MSR_APIC_START;
|
||||
|
||||
bql_lock();
|
||||
ret = apic_msr_read(index, &val);
|
||||
bql_unlock();
|
||||
if (ret < 0) {
|
||||
raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL
|
||||
&& (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue