reset.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2012,2013 - ARM Ltd
  3. * Author: Marc Zyngier <marc.zyngier@arm.com>
  4. *
  5. * Derived from arch/arm/kvm/reset.c
  6. * Copyright (C) 2012 - Virtual Open Systems and Columbia University
  7. * Author: Christoffer Dall <c.dall@virtualopensystems.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <linux/errno.h>
  22. #include <linux/kvm_host.h>
  23. #include <linux/kvm.h>
  24. #include <asm/cputype.h>
  25. #include <asm/ptrace.h>
  26. #include <asm/kvm_arm.h>
  27. #include <asm/kvm_coproc.h>
  28. /*
  29. * ARMv8 Reset Values
  30. */
  31. static const struct kvm_regs default_regs_reset = {
  32. .regs.pstate = (PSR_MODE_EL1h | PSR_A_BIT | PSR_I_BIT |
  33. PSR_F_BIT | PSR_D_BIT),
  34. };
  35. int kvm_arch_dev_ioctl_check_extension(long ext)
  36. {
  37. int r;
  38. switch (ext) {
  39. default:
  40. r = 0;
  41. }
  42. return r;
  43. }
  44. /**
  45. * kvm_reset_vcpu - sets core registers and sys_regs to reset value
  46. * @vcpu: The VCPU pointer
  47. *
  48. * This function finds the right table above and sets the registers on
  49. * the virtual CPU struct to their architectually defined reset
  50. * values.
  51. */
  52. int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
  53. {
  54. const struct kvm_regs *cpu_reset;
  55. switch (vcpu->arch.target) {
  56. default:
  57. cpu_reset = &default_regs_reset;
  58. break;
  59. }
  60. /* Reset core registers */
  61. memcpy(vcpu_gp_regs(vcpu), cpu_reset, sizeof(*cpu_reset));
  62. /* Reset system registers */
  63. kvm_reset_sys_regs(vcpu);
  64. return 0;
  65. }