mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 05:48:40 +00:00
KVM: ia64: Fix kvm_arch_vcpu_ioctl_[gs]et_regs()
Fix kvm_arch_vcpu_ioctl_[gs]et_regs() to do something meaningful on ia64. Old versions could never have worked since they required pointers to be set in the ioctl payload which were never being set by the ioctl handler for get_regs. In addition reserve extra space for future extensions. The change of layout of struct kvm_regs doesn't require adding a new CAP since get/set regs never worked on ia64 until now. This version doesn't support copying the KVM kernel stack in/out of the kernel. This should be implemented in a seperate ioctl call if ever needed. Signed-off-by: Jes Sorensen <jes@sgi.com> Acked-by : Xiantao Zhang <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
4531220b71
commit
042b26edf0
2 changed files with 14 additions and 32 deletions
|
@ -166,8 +166,6 @@ struct saved_vpd {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kvm_regs {
|
struct kvm_regs {
|
||||||
char *saved_guest;
|
|
||||||
char *saved_stack;
|
|
||||||
struct saved_vpd vpd;
|
struct saved_vpd vpd;
|
||||||
/*Arch-regs*/
|
/*Arch-regs*/
|
||||||
int mp_state;
|
int mp_state;
|
||||||
|
@ -200,6 +198,10 @@ struct kvm_regs {
|
||||||
unsigned long fp_psr; /*used for lazy float register */
|
unsigned long fp_psr; /*used for lazy float register */
|
||||||
unsigned long saved_gp;
|
unsigned long saved_gp;
|
||||||
/*for phycial emulation */
|
/*for phycial emulation */
|
||||||
|
|
||||||
|
union context saved_guest;
|
||||||
|
|
||||||
|
unsigned long reserved[64]; /* for future use */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kvm_sregs {
|
struct kvm_sregs {
|
||||||
|
|
|
@ -831,9 +831,8 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
|
||||||
|
|
||||||
int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd);
|
struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd);
|
||||||
int r;
|
int i;
|
||||||
|
|
||||||
vcpu_load(vcpu);
|
vcpu_load(vcpu);
|
||||||
|
|
||||||
|
@ -850,18 +849,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
||||||
|
|
||||||
vpd->vpr = regs->vpd.vpr;
|
vpd->vpr = regs->vpd.vpr;
|
||||||
|
|
||||||
r = -EFAULT;
|
memcpy(&vcpu->arch.guest, ®s->saved_guest, sizeof(union context));
|
||||||
r = copy_from_user(&vcpu->arch.guest, regs->saved_guest,
|
|
||||||
sizeof(union context));
|
|
||||||
if (r)
|
|
||||||
goto out;
|
|
||||||
r = copy_from_user(vcpu + 1, regs->saved_stack +
|
|
||||||
sizeof(struct kvm_vcpu),
|
|
||||||
KVM_STK_OFFSET - sizeof(struct kvm_vcpu));
|
|
||||||
if (r)
|
|
||||||
goto out;
|
|
||||||
vcpu->arch.exit_data =
|
|
||||||
((struct kvm_vcpu *)(regs->saved_stack))->arch.exit_data;
|
|
||||||
|
|
||||||
RESTORE_REGS(mp_state);
|
RESTORE_REGS(mp_state);
|
||||||
RESTORE_REGS(vmm_rr);
|
RESTORE_REGS(vmm_rr);
|
||||||
|
@ -895,9 +883,8 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
||||||
set_bit(KVM_REQ_RESUME, &vcpu->requests);
|
set_bit(KVM_REQ_RESUME, &vcpu->requests);
|
||||||
|
|
||||||
vcpu_put(vcpu);
|
vcpu_put(vcpu);
|
||||||
r = 0;
|
|
||||||
out:
|
return 0;
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long kvm_arch_vm_ioctl(struct file *filp,
|
long kvm_arch_vm_ioctl(struct file *filp,
|
||||||
|
@ -1378,9 +1365,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
|
||||||
|
|
||||||
int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int r;
|
|
||||||
struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd);
|
struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd);
|
||||||
|
int i;
|
||||||
|
|
||||||
vcpu_load(vcpu);
|
vcpu_load(vcpu);
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
|
@ -1395,14 +1382,8 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
||||||
regs->vpd.vpsr = vpd->vpsr;
|
regs->vpd.vpsr = vpd->vpsr;
|
||||||
regs->vpd.vpr = vpd->vpr;
|
regs->vpd.vpr = vpd->vpr;
|
||||||
|
|
||||||
r = -EFAULT;
|
memcpy(®s->saved_guest, &vcpu->arch.guest, sizeof(union context));
|
||||||
r = copy_to_user(regs->saved_guest, &vcpu->arch.guest,
|
|
||||||
sizeof(union context));
|
|
||||||
if (r)
|
|
||||||
goto out;
|
|
||||||
r = copy_to_user(regs->saved_stack, (void *)vcpu, KVM_STK_OFFSET);
|
|
||||||
if (r)
|
|
||||||
goto out;
|
|
||||||
SAVE_REGS(mp_state);
|
SAVE_REGS(mp_state);
|
||||||
SAVE_REGS(vmm_rr);
|
SAVE_REGS(vmm_rr);
|
||||||
memcpy(regs->itrs, vcpu->arch.itrs, sizeof(struct thash_data) * NITRS);
|
memcpy(regs->itrs, vcpu->arch.itrs, sizeof(struct thash_data) * NITRS);
|
||||||
|
@ -1430,10 +1411,9 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
|
||||||
SAVE_REGS(metaphysical_saved_rr4);
|
SAVE_REGS(metaphysical_saved_rr4);
|
||||||
SAVE_REGS(fp_psr);
|
SAVE_REGS(fp_psr);
|
||||||
SAVE_REGS(saved_gp);
|
SAVE_REGS(saved_gp);
|
||||||
|
|
||||||
vcpu_put(vcpu);
|
vcpu_put(vcpu);
|
||||||
r = 0;
|
return 0;
|
||||||
out:
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
|
void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
|
||||||
|
|
Loading…
Reference in a new issue