s2-setup.c 995 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (C) 2016 - ARM Ltd
  3. * Author: Marc Zyngier <marc.zyngier@arm.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <linux/types.h>
  18. #include <asm/kvm_arm.h>
  19. #include <asm/kvm_asm.h>
  20. #include <asm/kvm_hyp.h>
  21. void __hyp_text __init_stage2_translation(void)
  22. {
  23. u64 val;
  24. val = read_sysreg(VTCR) & ~VTCR_MASK;
  25. val |= read_sysreg(HTCR) & VTCR_HTCR_SH;
  26. val |= KVM_VTCR_SL0 | KVM_VTCR_T0SZ | KVM_VTCR_S;
  27. write_sysreg(val, VTCR);
  28. }