mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
target/ppc, spapr: Move VPA information to machine_data
CPUPPCState currently contains a number of fields containing the state of the VPA. The VPA is a PAPR specific concept covering several guest/host shared memory areas used to communicate some information with the hypervisor. As a PAPR concept this is really machine specific information, although it is per-cpu, so it doesn't really belong in the core CPU state structure. There's also other information that's per-cpu, but platform/machine specific. So create a (void *)machine_data in PowerPCCPU which can be used by the machine to locate per-cpu data. Intialization, lifetime and cleanup of machine_data is entirely up to the machine type. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Greg Kurz <groug@kaod.org> Tested-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
parent
51c047283c
commit
7388efafc2
6 changed files with 88 additions and 67 deletions
|
@ -829,22 +829,22 @@ static int kvm_get_fp(CPUState *cs)
|
|||
static int kvm_get_vpa(CPUState *cs)
|
||||
{
|
||||
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
||||
CPUPPCState *env = &cpu->env;
|
||||
sPAPRCPUState *spapr_cpu = spapr_cpu_state(cpu);
|
||||
struct kvm_one_reg reg;
|
||||
int ret;
|
||||
|
||||
reg.id = KVM_REG_PPC_VPA_ADDR;
|
||||
reg.addr = (uintptr_t)&env->vpa_addr;
|
||||
reg.addr = (uintptr_t)&spapr_cpu->vpa_addr;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
|
||||
if (ret < 0) {
|
||||
DPRINTF("Unable to get VPA address from KVM: %s\n", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
assert((uintptr_t)&env->slb_shadow_size
|
||||
== ((uintptr_t)&env->slb_shadow_addr + 8));
|
||||
assert((uintptr_t)&spapr_cpu->slb_shadow_size
|
||||
== ((uintptr_t)&spapr_cpu->slb_shadow_addr + 8));
|
||||
reg.id = KVM_REG_PPC_VPA_SLB;
|
||||
reg.addr = (uintptr_t)&env->slb_shadow_addr;
|
||||
reg.addr = (uintptr_t)&spapr_cpu->slb_shadow_addr;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
|
||||
if (ret < 0) {
|
||||
DPRINTF("Unable to get SLB shadow state from KVM: %s\n",
|
||||
|
@ -852,9 +852,10 @@ static int kvm_get_vpa(CPUState *cs)
|
|||
return ret;
|
||||
}
|
||||
|
||||
assert((uintptr_t)&env->dtl_size == ((uintptr_t)&env->dtl_addr + 8));
|
||||
assert((uintptr_t)&spapr_cpu->dtl_size
|
||||
== ((uintptr_t)&spapr_cpu->dtl_addr + 8));
|
||||
reg.id = KVM_REG_PPC_VPA_DTL;
|
||||
reg.addr = (uintptr_t)&env->dtl_addr;
|
||||
reg.addr = (uintptr_t)&spapr_cpu->dtl_addr;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®);
|
||||
if (ret < 0) {
|
||||
DPRINTF("Unable to get dispatch trace log state from KVM: %s\n",
|
||||
|
@ -868,7 +869,7 @@ static int kvm_get_vpa(CPUState *cs)
|
|||
static int kvm_put_vpa(CPUState *cs)
|
||||
{
|
||||
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
||||
CPUPPCState *env = &cpu->env;
|
||||
sPAPRCPUState *spapr_cpu = spapr_cpu_state(cpu);
|
||||
struct kvm_one_reg reg;
|
||||
int ret;
|
||||
|
||||
|
@ -876,11 +877,12 @@ static int kvm_put_vpa(CPUState *cs)
|
|||
* registered. That means when restoring state, if a VPA *is*
|
||||
* registered, we need to set that up first. If not, we need to
|
||||
* deregister the others before deregistering the master VPA */
|
||||
assert(env->vpa_addr || !(env->slb_shadow_addr || env->dtl_addr));
|
||||
assert(spapr_cpu->vpa_addr
|
||||
|| !(spapr_cpu->slb_shadow_addr || spapr_cpu->dtl_addr));
|
||||
|
||||
if (env->vpa_addr) {
|
||||
if (spapr_cpu->vpa_addr) {
|
||||
reg.id = KVM_REG_PPC_VPA_ADDR;
|
||||
reg.addr = (uintptr_t)&env->vpa_addr;
|
||||
reg.addr = (uintptr_t)&spapr_cpu->vpa_addr;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
|
||||
if (ret < 0) {
|
||||
DPRINTF("Unable to set VPA address to KVM: %s\n", strerror(errno));
|
||||
|
@ -888,19 +890,20 @@ static int kvm_put_vpa(CPUState *cs)
|
|||
}
|
||||
}
|
||||
|
||||
assert((uintptr_t)&env->slb_shadow_size
|
||||
== ((uintptr_t)&env->slb_shadow_addr + 8));
|
||||
assert((uintptr_t)&spapr_cpu->slb_shadow_size
|
||||
== ((uintptr_t)&spapr_cpu->slb_shadow_addr + 8));
|
||||
reg.id = KVM_REG_PPC_VPA_SLB;
|
||||
reg.addr = (uintptr_t)&env->slb_shadow_addr;
|
||||
reg.addr = (uintptr_t)&spapr_cpu->slb_shadow_addr;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
|
||||
if (ret < 0) {
|
||||
DPRINTF("Unable to set SLB shadow state to KVM: %s\n", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
assert((uintptr_t)&env->dtl_size == ((uintptr_t)&env->dtl_addr + 8));
|
||||
assert((uintptr_t)&spapr_cpu->dtl_size
|
||||
== ((uintptr_t)&spapr_cpu->dtl_addr + 8));
|
||||
reg.id = KVM_REG_PPC_VPA_DTL;
|
||||
reg.addr = (uintptr_t)&env->dtl_addr;
|
||||
reg.addr = (uintptr_t)&spapr_cpu->dtl_addr;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
|
||||
if (ret < 0) {
|
||||
DPRINTF("Unable to set dispatch trace log state to KVM: %s\n",
|
||||
|
@ -908,9 +911,9 @@ static int kvm_put_vpa(CPUState *cs)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (!env->vpa_addr) {
|
||||
if (!spapr_cpu->vpa_addr) {
|
||||
reg.id = KVM_REG_PPC_VPA_ADDR;
|
||||
reg.addr = (uintptr_t)&env->vpa_addr;
|
||||
reg.addr = (uintptr_t)&spapr_cpu->vpa_addr;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®);
|
||||
if (ret < 0) {
|
||||
DPRINTF("Unable to set VPA address to KVM: %s\n", strerror(errno));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue