b9ef152b | 26-Aug-2024 |
Mark Johnston <markj@FreeBSD.org> |
vmm: Merge vmm_dev.c
This file contains the vmm device file implementation. Most of this code is not machine-dependent and so shouldn't be duplicated this way. Move most of it into a generic dev/vm
vmm: Merge vmm_dev.c
This file contains the vmm device file implementation. Most of this code is not machine-dependent and so shouldn't be duplicated this way. Move most of it into a generic dev/vmm/vmm_dev.c. This will make it easier to introduce a cdev-based interface for VM creation, which in turn makes it possible to implement support for running bhyve as an unprivileged user.
Machine-dependent ioctls continue to be handled in machine-dependent code. To make the split a bit easier to handle, introduce a pair of tables which define MI and MD ioctls. Each table entry can set flags which determine which locks need to be held in order to execute the handler. vmmdev_ioctl() now looks up the ioctl in one of the tables, acquires locks and either handles the ioctl directly or calls vmmdev_machdep_ioctl() to handle it.
No functional change intended. There is a lot of churn in this change but the underlying logic in the ioctl handlers is the same. For now, vmm_dev.h is still mostly separate, even though some parts could be merged in principle. This would involve changing include paths for userspace, though.
Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D46431
show more ...
|
908a9dc0 | 26-Aug-2024 |
Mark Johnston <markj@FreeBSD.org> |
arm64: Add a missing vm_disable_vcpu_creation() call in vmmdev_destroy()
This brings arm64 in sync with amd64, which had diverged a bit after the arm64 code was forked.
Reviewed by: jhb Differentia
arm64: Add a missing vm_disable_vcpu_creation() call in vmmdev_destroy()
This brings arm64 in sync with amd64, which had diverged a bit after the arm64 code was forked.
Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D46439
show more ...
|
3df92c97 | 26-Aug-2024 |
Mark Johnston <markj@FreeBSD.org> |
vmm: Enable assertions in vmmdev_lookup()
The comment has been there since the initial import of the vmm code and presumably reflected some kind of problem with standalone builds of vmm.ko. However
vmm: Enable assertions in vmmdev_lookup()
The comment has been there since the initial import of the vmm code and presumably reflected some kind of problem with standalone builds of vmm.ko. However, I don't see any problems with it, and mtx_assert() is used elsewhere within the vmm code.
Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D46438
show more ...
|
93e81baa | 26-Aug-2024 |
Mark Johnston <markj@FreeBSD.org> |
vmm: Move duplicated stats code into a generic file
There is a small difference between the arm64 and amd64 implementations: the latter makes use of a "scope" to exclude AMD-specific stats on Intel
vmm: Move duplicated stats code into a generic file
There is a small difference between the arm64 and amd64 implementations: the latter makes use of a "scope" to exclude AMD-specific stats on Intel systems and vice-versa. Replace this with a more generic predicate callback which can be used for the same purpose.
No functional change intended.
Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D46430
show more ...
|
7279fa6a | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Convert the handlers into ifuncs
Now we have support for both VHE and non-VHE update the handlers to use an ifunc to decide which version to use.
Sponsored by: Arm Ltd Differential Revis
arm64/vmm: Convert the handlers into ifuncs
Now we have support for both VHE and non-VHE update the handlers to use an ifunc to decide which version to use.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46084
show more ...
|
b87952e8 | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Mark asm files as supporting BTI
These already support BTI as they use the ENTRY macro. While the non-VHE code doesn't need this the new VHE code will need it as it is linked into either
arm64/vmm: Mark asm files as supporting BTI
These already support BTI as they use the ENTRY macro. While the non-VHE code doesn't need this the new VHE code will need it as it is linked into either the kernel or the vmm module so will be included in the BTI check.
Sponsored by: Arm Ltd
show more ...
|
79a19e0e | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Hide non-VHE exception code from VHE
Remove the non-VHE exception code from the VHE code path. As we replace the exception vectors when entering the guest we don't need to check which con
arm64/vmm: Hide non-VHE exception code from VHE
Remove the non-VHE exception code from the VHE code path. As we replace the exception vectors when entering the guest we don't need to check which context we are in so can skip parts of the exception vectors.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46082
show more ...
|
f83a0f38 | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Update exception vectors around a guest
When entering into a guest with VHE we need to switch from the kernel exception vectors to the vmm exception vectors. The latter understands an exc
arm64/vmm: Update exception vectors around a guest
When entering into a guest with VHE we need to switch from the kernel exception vectors to the vmm exception vectors. The latter understands an exception will be from a guest and can switch back to a kernel context.
Rather than encoding the location of the kernel vectors we can just read the value from vbar_el2 and restore it later.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46081
show more ...
|
5577bb2f | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Support tlbi from VHE
When invalidating the stage 2 TLB we need to ensure page tables updates have completed and for tlbi vmalle1is the HCR_EL2 TGE flag needs to be clear.
To fix the for
arm64/vmm: Support tlbi from VHE
When invalidating the stage 2 TLB we need to ensure page tables updates have completed and for tlbi vmalle1is the HCR_EL2 TGE flag needs to be clear.
To fix the former add a data barrier before the tlbi instructions. On non-VHE this will happen as part of the exception entry, so is only needed for VHE.
The tlbi vmalle1is instruction operates on the EL2 & 0 regime when HCR_EL2 E2H and TGE flags are both set. By clearing the TGE flag it will stop this and operate on the EL1 & 0 regime we are expecting.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46080
show more ...
|
20eabb33 | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Only store the guest par_el1
There is no need to store the host par_el1. We don't depend on it not changing across calls into a guest.
Sponsored by: Arm Ltd Differential Revision: https:
arm64/vmm: Only store the guest par_el1
There is no need to store the host par_el1. We don't depend on it not changing across calls into a guest.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46079
show more ...
|
7861ecd1 | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Teach the switcher about new registers
To support booting the kernel in EL2 some of the EL0 and EL1 registers are changed to point to an EL2 version. To get access to the EL0/EL1 version
arm64/vmm: Teach the switcher about new registers
To support booting the kernel in EL2 some of the EL0 and EL1 registers are changed to point to an EL2 version. To get access to the EL0/EL1 version of these registers we need to use the new EL02 and EL12 registers, e.g. to access elr_el1 from the host we would use elr_el12.
Add macros that can be different on VHE vs non-VHE code so these registers can be accessed in the correct way.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46078
show more ...
|
387f878a | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Teach vmm_arm.c about VHE
Most of the code is identical however some, e.g. managing EL2 memory or setting EL2 registers, are unneeded under VHE as the kernel is in EL2 so can manage these
arm64/vmm: Teach vmm_arm.c about VHE
Most of the code is identical however some, e.g. managing EL2 memory or setting EL2 registers, are unneeded under VHE as the kernel is in EL2 so can manage these directly.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46076
show more ...
|
a745cdc1 | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Teach the vtimer about VHE
Teach the virtual timer about the cnthctl_el2 field layout under VHE. As with non-VHE we need to trap the physical timer and not trap the virtual timer.
Sponso
arm64/vmm: Teach the vtimer about VHE
Teach the virtual timer about the cnthctl_el2 field layout under VHE. As with non-VHE we need to trap the physical timer and not trap the virtual timer.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46074
show more ...
|
4b6c9f84 | 19-Aug-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64/vmm: Move nVHE-only code to the new file
There are some functions that are only needed in non-VHE mode. These are used to handle hypervisor calls from the kernel, and to manage the page tables
arm64/vmm: Move nVHE-only code to the new file
There are some functions that are only needed in non-VHE mode. These are used to handle hypervisor calls from the kernel, and to manage the page tables in EL2. As these won't be used by the VHE code we can move them to the non-VHE specific files.
Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46073
show more ...
|