Re: [RFC 0/4] Virtio uses DMA API for all devices
On Fri, Aug 03, 2018 at 01:58:46PM -0500, Benjamin Herrenschmidt wrote: > You are saying something along the lines of "I don't like an > instruction in your ISA, let's not support your entire CPU architecture > in Linux". No. I'm saying if you can't describe your architecture in the virtio spec document it is bogus. > Our setup is not fucked. It makes a LOT of sense and it's a very > sensible design. It's hitting a problem due to a corner case oddity in > virtio bypassing the MMU, we've worked around such corner cases many > times in the past without any problem, I fail to see what the problem > is here. No matter if you like it or not (I don't!) virtio is defined to bypass dma translations, it is very clearly stated in the spec. It has some ill-defined bits to bypass it, so if you want the dma mapping API to be used you'll have to set that bit (in its original form, a refined form, or an entirely newly defined sane form) and make sure your hypersivors always sets it. It's not rocket science, just a little bit for work to make sure your setup is actually going to work reliably and portably. > We aren't going to cancel years of HW and SW development for our Maybe you should have actually read the specs you are claiming to implemented before spending all that effort.
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Fri, Aug 03, 2018 at 10:17:32PM +0300, Michael S. Tsirkin wrote: > It seems reasonable to teach a platform to override dma-range > for a specific device e.g. in case it knows about bugs in ACPI. A platform will be able override dma-range using the dev->bus_dma_mask field starting in 4.19. But we'll still need a way how to a) document in the virtio spec that all bus dma quirks are to be applied b) a way to document in a virtio-related spec how the bus handles dma for Ben's totally fucked up hypervisor. Without that there is not way we'll get interoperable implementations.
Re: linux-next: manual merge of the powerpc tree with the m68k tree
On Thu, 2 Aug 2018, Geert Uytterhoeven wrote: > Hi Stephen, > > On Thu, Aug 2, 2018 at 1:42 AM Stephen Rothwell wrote: > > [forgot the conflict resolution ...] > > > > On Thu, 2 Aug 2018 09:27:20 +1000 Stephen Rothwell > > wrote: > > > > > > Today's linux-next merge of the powerpc tree got a conflict in: > > > > > > arch/m68k/mac/misc.c > > > > > > between commit: > > > > > > 5b9bfb8ec467 ("m68k: mac: Use time64_t in RTC handling") > > > > > > from the m68k tree and commit: > > > > > > ebd722275f9c ("macintosh/via-pmu: Replace via-pmu68k driver with > > > via-pmu driver") > > > > > > from the powerpc tree. > > > > > > I fixed it up (see below) and can carry the fix as necessary. This > > > is now fixed as far as linux-next is concerned, but any non trivial > > > conflicts should be mentioned to your upstream maintainer when your > > > tree is submitted for merging. You may also want to consider > > > cooperating with the maintainer of the conflicting tree to minimise > > > any particularly complex conflicts. > > Ah, now I remember Finn said he was going to rebase his series once the > time64_t patch has entered my tree... > The conflict I was worried about was avoided when I dropped v3 patch 10/12 ("macintosh: Use common code to access RTC"). I'll rework that patch after all the PMU and RTC work makes its way into Linus' tree. > > --- a/arch/m68k/mac/misc.c > > +++ b/arch/m68k/mac/misc.c > > @@@ -90,11 -85,11 +90,11 @@@ static void cuda_write_pram(int offset > > } > > #endif /* CONFIG_ADB_CUDA */ > > > > - #ifdef CONFIG_ADB_PMU68K > > + #ifdef CONFIG_ADB_PMU > > -static long pmu_read_time(void) > > +static time64_t pmu_read_time(void) > > { > > struct adb_request req; > > - long time; > > + time64_t time; > > > > if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0) > > return 0; > > Thanks, looks good to me! > Looks good to me, too. Thanks. -- > Gr{oetje,eeting}s, > > Geert > >
[PATCH] powpc:feature: of_node_put is not needed after iterator.
for_each_node_by_name iterators only exit normally when the loop cursor is NULL, So there is no point to call of_node_put. Signed-off-by: zhong jiang --- arch/powerpc/platforms/powermac/feature.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index 3f82cb2..4eb8cb3 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c @@ -2889,10 +2889,8 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ /* On all machines, switch modem & serial ports off */ for_each_node_by_name(np, "ch-a") initial_serial_shutdown(np); - of_node_put(np); for_each_node_by_name(np, "ch-b") initial_serial_shutdown(np); - of_node_put(np); } void __init -- 1.7.12.4
Re: [PATCH] powpc:feature: of_node_put is not needed after iterator.
On 08/04/2018 07:25 AM, zhong jiang wrote: > for_each_node_by_name iterators only exit normally when the loop > cursor is NULL, So there is no point to call of_node_put. > > Signed-off-by: zhong jiang Reviewed-by: Tyrel Datwyler > --- > arch/powerpc/platforms/powermac/feature.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/arch/powerpc/platforms/powermac/feature.c > b/arch/powerpc/platforms/powermac/feature.c > index 3f82cb2..4eb8cb3 100644 > --- a/arch/powerpc/platforms/powermac/feature.c > +++ b/arch/powerpc/platforms/powermac/feature.c > @@ -2889,10 +2889,8 @@ static void __init probe_one_macio(const char *name, > const char *compat, int typ > /* On all machines, switch modem & serial ports off */ > for_each_node_by_name(np, "ch-a") > initial_serial_shutdown(np); > - of_node_put(np); > for_each_node_by_name(np, "ch-b") > initial_serial_shutdown(np); > - of_node_put(np); > } > > void __init >
Re: vio.c:__vio_register_driver && LPAR Migration issue
On 08/03/2018 02:23 PM, Tyrel Datwyler wrote: > On 08/02/2018 11:15 AM, Michael Bringmann wrote: >> Hello: >> I have been observing an anomaly during LPAR migrations between >> a couple of P8 systems. >> >> This is the problem. After migrating an LPAR, the PPC mobility code >> receives RTAS requests to delete nodes with platform-/hardware-specific >> attributes when restarting the kernel after a migration. My example is >> for migration between a P8 Alpine and a P8 Brazos. Among the nodes >> that I see being deleted are 'ibm,random-v1', 'ibm,compression-v1', >> 'ibm,platform-facilities', and 'ibm,sym-encryption-v1'. Of these >> nodes, the following are created during initial boot by calls to >> vio_register_driver: >> >> drivers/char/hw_random/pseries-rng.c >> ibm,random-v1 >> >> drivers/crypto/nx/nx-842-pseries.c >> ibm,compression-v1 >> >> drivers/crypto/nx/nx.c >> ibm,sym-encryption-v1 >> >> After the migration, these nodes are deleted, but nothing recreates >> them. If I boot the LPAR on the target system, the nodes are added >> again. >> >> My question is how do we recreate these nodes after migration? > > Hmm, I'd have to see the scenario in action, but these should be added back > by ibm,update-nodes RTAS call. There is some debug code in > driver/of/dynamic.c that can be enabled that will log node/property dynamic > reconfiguration events. > I took a quick look by turning of phandle caching and turning on the OF reconfig debug on one of my lpars. I noticed that it looks like this could be a firmware issue. Looks to me like we aren't being notified to re-add those child nodes of ibm,platform-facilities. [ 1671.638041] OF: notify DETACH_NODE /cpus/l2-cache@2022 [ 1671.638094] OF: notify DETACH_NODE /cpus/l3-cache@3122 [ 1671.638119] OF: notify DETACH_NODE /cpus/l2-cache@2023 [ 1671.638136] OF: notify DETACH_NODE /cpus/l3-cache@3123 [ 1671.638164] OF: notify DETACH_NODE /ibm,platform-facilities/ibm,random-v1 [ 1671.638182] OF: notify DETACH_NODE /ibm,platform-facilities/ibm,compression-v1 [ 1671.638198] OF: notify DETACH_NODE /ibm,platform-facilities/ibm,sym-encryption-v1 [ 1671.638219] OF: notify DETACH_NODE /ibm,platform-facilities [ 1671.776419] OF: notify UPDATE_PROPERTY /:ibm,model-class ... snipped property updates [ 1672.129941] OF: notify UPDATE_PROPERTY /cpus/PowerPC,POWER8@8:ibm,dfp [ 1672.147551] OF: notify ATTACH_NODE /cpus/l2-cache@202e [ 1672.166321] OF: notify ATTACH_NODE /cpus/l3-cache@312e [ 1672.183971] OF: notify ATTACH_NODE /cpus/l2-cache@202f [ 1672.202752] OF: notify ATTACH_NODE /cpus/l3-cache@312f [ 1672.230760] OF: notify ATTACH_NODE /ibm,platform-facilities Need to verify this by tracing the RTAS calls to ibm,update-nodes. I'll try and look at that tomorrow. The loop that processes the nodes to update in pseries_devicetree_update() blindly ignores the return codes from delete_dt_node(), update_dt_node(), and add_dt_node(). So, it is also possible that we are notified, but are silently failing the add. -Tyrel
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Sat, Aug 04, 2018 at 01:15:00AM -0700, Christoph Hellwig wrote: > On Fri, Aug 03, 2018 at 10:17:32PM +0300, Michael S. Tsirkin wrote: > > It seems reasonable to teach a platform to override dma-range > > for a specific device e.g. in case it knows about bugs in ACPI. > > A platform will be able override dma-range using the dev->bus_dma_mask > field starting in 4.19. But we'll still need a way how to > > a) document in the virtio spec that all bus dma quirks are to be > applied I agree it's a good idea. In particular I suspect that PLATFORM_IOMMU should be extended to cover that. But see below. > b) a way to document in a virtio-related spec how the bus handles > dma for Ben's totally fucked up hypervisor. Without that there > is not way we'll get interoperable implementations. So in this case however I'm not sure what exactly do we want to add. It seems that from point of view of the device, there is nothing special - it just gets a PA and writes there. It also seems that guest does not need to get any info from the device either. Instead guest itself needs device to DMA into specific addresses, for its own reasons. It seems that the fact that within guest it's implemented using a bounce buffer and that it's easiest to do by switching virtio to use the DMA API isn't something virtio spec concerns itself with. I'm open to suggestions. -- MST
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Fri, Aug 03, 2018 at 08:16:21PM -0500, Benjamin Herrenschmidt wrote: > On Fri, 2018-08-03 at 22:07 +0300, Michael S. Tsirkin wrote: > > On Fri, Aug 03, 2018 at 10:58:36AM -0500, Benjamin Herrenschmidt wrote: > > > On Fri, 2018-08-03 at 00:05 -0700, Christoph Hellwig wrote: > > > > > 2- Make virtio use the DMA API with our custom platform-provided > > > > > swiotlb callbacks when needed, that is when not using IOMMU *and* > > > > > running on a secure VM in our case. > > > > > > > > And total NAK the customer platform-provided part of this. We need > > > > a flag passed in from the hypervisor that the device needs all bus > > > > specific dma api treatment, and then just use the normal plaform > > > > dma mapping setup. > > > > > > Christoph, as I have explained already, we do NOT have a way to provide > > > such a flag as neither the hypervisor nor qemu knows anything about > > > this when the VM is created. > > > > I think the fact you can't add flags from the hypervisor is > > a sign of a problematic architecture, you should look at > > adding that down the road - you will likely need it at some point. > > Well, we can later in the boot process. At VM creation time, it's just > a normal VM. The VM firmware, bootloader etc... are just operating > normally etc... I see the allure of this, but I think down the road you will discover passing a flag in libvirt XML saying "please use a secure mode" or whatever is a good idea. Even thought it is probably not required to address this specific issue. For example, I don't think ballooning works in secure mode, you will be able to teach libvirt not to try to add a balloon to the guest. > Later on, (we may have even already run Linux at that point, > unsecurely, as we can use Linux as a bootloader under some > circumstances), we start a "secure image". > > This is a kernel zImage that includes a "ticket" that has the > appropriate signature etc... so that when that kernel starts, it can > authenticate with the ultravisor, be verified (along with its ramdisk) > etc... and copied (by the UV) into secure memory & run from there. > > At that point, the hypervisor is informed that the VM has become > secure. > > So at that point, we could exit to qemu to inform it of the change, That's probably a good idea too. > and > have it walk the qtree and "Switch" all the virtio devices to use the > IOMMU I suppose, but it feels a lot grosser to me. That part feels gross, yes. > That's the only other option I can think of. > > > However in this specific case, the flag does not need to come from the > > hypervisor, it can be set by arch boot code I think. > > Christoph do you see a problem with that? > > The above could do that yes. Another approach would be to do it from a > small virtio "quirk" that pokes a bit in the device to force it to > iommu mode when it detects that we are running in a secure VM. That's a > bit warty on the virito side but probably not as much as having a qemu > one that walks of the virtio devices to change how they behave. > > What do you reckon ? I think you are right that for the dma limit the hypervisor doesn't seem to need to know. > What we want to avoid is to expose any of this to the *end user* or > libvirt or any other higher level of the management stack. We really > want that stuff to remain contained between the VM itself, KVM and > maybe qemu. > > We will need some other qemu changes for migration so that's ok. But > the minute you start touching libvirt and the higher levels it becomes > a nightmare. > > Cheers, > Ben. I don't believe you'll be able to avoid that entirely. The split between libvirt and qemu is more about community than about code, random bits of functionality tend to land on random sides of that fence. Better add a tag in domain XML early is my advice. Having said that, it's your hypervisor. I'm just suggesting that when hypervisor does somehow need to care then I suspect most people won't be receptive to the argument that changing libvirt is a nightmare. > > > > To get swiotlb you'll need to then use the DT/ACPI > > > > dma-range property to limit the addressable range, and a swiotlb > > > > capable plaform will use swiotlb automatically. > > > > > > This cannot be done as you describe it. > > > > > > The VM is created as a *normal* VM. The DT stuff is generated by qemu > > > at a point where it has *no idea* that the VM will later become secure > > > and thus will have to restrict which pages can be used for "DMA". > > > > > > The VM will *at runtime* turn itself into a secure VM via interactions > > > with the security HW and the Ultravisor layer (which sits below the > > > HV). This happens way after the DT has been created and consumed, the > > > qemu devices instanciated etc... > > > > > > Only the guest kernel knows because it initates the transition. When > > > that happens, the virtio devices have already been used by the guest > > > firmware, bootloader, possibly another kernel t
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Fri, Aug 03, 2018 at 08:22:11PM -0500, Benjamin Herrenschmidt wrote: > (Appologies if you got this twice, my mailer had a brain fart and I don't > know if the first one got through & am about to disappear in a plane for 17h) I got like 3 of these. I hope that's true for everyone as I replied to 1st one.
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Fri, Aug 03, 2018 at 08:21:26PM -0500, Benjamin Herrenschmidt wrote: > On Fri, 2018-08-03 at 22:08 +0300, Michael S. Tsirkin wrote: > > > > > Please go through these patches and review whether this approach > > > > > broadly > > > > > makes sense. I will appreciate suggestions, inputs, comments regarding > > > > > the patches or the approach in general. Thank you. > > > > > > > > Jason did some work on profiling this. Unfortunately he reports > > > > about 4% extra overhead from this switch on x86 with no vIOMMU. > > > > > > The test is rather simple, just run pktgen (pktgen_sample01_simple.sh) in > > > guest and measure PPS on tap on host. > > > > > > Thanks > > > > Could you supply host configuration involved please? > > I wonder how much of that could be caused by Spectre mitigations > blowing up indirect function calls... > > Cheers, > Ben. I won't be surprised. If yes I suggested a way to mitigate the overhead. -- MSR
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Wed, Aug 01, 2018 at 09:16:38AM +0100, Will Deacon wrote: > On Tue, Jul 31, 2018 at 03:36:22PM -0500, Benjamin Herrenschmidt wrote: > > On Tue, 2018-07-31 at 10:30 -0700, Christoph Hellwig wrote: > > > > However the question people raise is that DMA API is already full of > > > > arch-specific tricks the likes of which are outlined in your post linked > > > > above. How is this one much worse? > > > > > > None of these warts is visible to the driver, they are all handled in > > > the architecture (possibly on a per-bus basis). > > > > > > So for virtio we really need to decide if it has one set of behavior > > > as specified in the virtio spec, or if it behaves exactly as if it > > > was on a PCI bus, or in fact probably both as you lined up. But no > > > magic arch specific behavior inbetween. > > > > The only arch specific behaviour is needed in the case where it doesn't > > behave like PCI. In this case, the PCI DMA ops are not suitable, but in > > our secure VMs, we still need to make it use swiotlb in order to bounce > > through non-secure pages. > > On arm/arm64, the problem we have is that legacy virtio devices on the MMIO > transport (so definitely not PCI) have historically been advertised by qemu > as not being cache coherent, but because the virtio core has bypassed DMA > ops then everything has happened to work. If we blindly enable the arch DMA > ops, we'll plumb in the non-coherent ops and start getting data corruption, > so we do need a way to quirk virtio as being "always coherent" if we want to > use the DMA ops (which we do, because our emulation platforms have an IOMMU > for all virtio devices). > > Will Right that's not very different from placing the device within the IOMMU domain but in fact bypassing the IOMMU. I wonder whether anyone ever needs a non coherent virtio-mmio. If yes we can extend PLATFORM_IOMMU to cover that or add another bit. What exactly do the non-coherent ops do that causes the corruption? -- MST
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Sat, 2018-08-04 at 01:15 -0700, Christoph Hellwig wrote: > b) a way to document in a virtio-related spec how the bus handles > dma for Ben's totally fucked up hypervisor. Without that there > is not way we'll get interoperable implementations. Christoph, this isn't a totally fucked up hypervisor. It's not even about the hypervisor itself, I mean seriously, man, can you at least bother reading what I described is going on with the security architecture ? Anyway, Michael is onto what could possibly be an alternative approach, by having us tell qemu to flip to iommu mode at secure VM boot time. Let's see where that leads. Cheers, Ben.
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Sat, 2018-08-04 at 01:21 -0700, Christoph Hellwig wrote: > No matter if you like it or not (I don't!) virtio is defined to bypass > dma translations, it is very clearly stated in the spec. It has some > ill-defined bits to bypass it, so if you want the dma mapping API > to be used you'll have to set that bit (in its original form, a refined > form, or an entirely newly defined sane form) and make sure your > hypersivors always sets it. It's not rocket science, just a little bit > for work to make sure your setup is actually going to work reliably > and portably. I think you are conflating completely different things, let me try to clarify, we might actually be talking past each other. > > We aren't going to cancel years of HW and SW development for our > > Maybe you should have actually read the specs you are claiming to > implemented before spending all that effort. Anyway, let's cool our respective jets and sort that out, there are indeed other approaches than overriding the DMA ops with special ones, though I find them less tasty ... but here's my attempt at a (simpler) description. Bear with me for the long-ish email, this tries to describe the system so you get an idea where we come from, and options we can use to get out of this. So we *are* implementing the spec, since qemu is currently unmodified: Default virtio will bypass the iommu emulated by qemu as per spec etc.. On the Linux side, thus, virtio "sees" a normal iommu-bypassing device and will treat it as such. The problem is the assumption in the middle that qemu can access all guest pages directly, which holds true for traditional VMs, but breaks when the VM in our case turns itself into a secure VM. This isn't under the action (or due to changes in) the hypervisor. KVM operates (almost) normally here. But there's this (very thin and open source btw) layer underneath called ultravisor, which exploits some HW facilities to maintain a separate pool of "secure" memory, which cannot be physically accessed by a non-secure entity. So in our scenario, qemu and KVM create a VM totally normally, there is no changes required to the VM firmware, bootloader(s), etc... in fact we support Linux based bootloaders, and those will work as normal linux would in a VM, virtio works normally, etc... Until that VM (via grub or kexec for example) loads a "secure image". That secure image is a Linux kernel which has been "wrapped" (to simply imagine a modified zImage wrapper though that's not entirely exact). When that is run, before it modifies it's .data, it will interact with the ultravisor using a specific HW facility to make itself secure. What happens then is that the UV cryptographically verifies the kernel and ramdisk, and copies them to the secure memory where execution returns. The Ultravisor is then involved as a small shim for hypercalls between the secure VM and KVM to prevent leakage of information (sanitize registers etc...). Now at this point, qemu can no longer access the secure VM pages (there's more to this, such as using HMM to allow migration/encryption accross etc... but let's not get bogged down). So virtio can no longer access any page in the VM. Now the VM *can* request from the Ultravisor some selected pages to be made "insecure" and thus shared with qemu. This is how we handle some of the pages used in our paravirt stuff, and that's how we want to deal with virtio, by creating an insecure swiotlb pool. At this point, thus, there are two options. - One you have rejected, which is to have a way for "no-iommu" virtio (which still doesn't use an iommu on the qemu side and doesn't need to), to be forced to use some custom DMA ops on the VM side. - One, which sadly has more overhead and will require modifying more pieces of the puzzle, which is to make qemu uses an emulated iommu. Once we make qemu do that, we can then layer swiotlb on top of the emulated iommu on the guest side, and pass that as dma_ops to virtio. Now, assuming you still absolutely want us to go down the second option, there are several ways to get there. We would prefer to avoid requiring the user to pass some special option to qemu. That has an impact up the food chain (libvirt, management tools etc...) and users probably won't understand what it's about. In fact the *end user* might not even need to know a VM is secure, though applications inside might. There's the additional annoyance that currently our guest FW (SLOF) cannot deal with virtio in IOMMU mode, but that's fixable. >From there, refer to the email chain between Michael and I where we are discussing options to "switch" virtio at runtime on the qemu side. Any comment or suggestion ? Cheers, Ben.
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Sun, 2018-08-05 at 03:09 +0300, Michael S. Tsirkin wrote: > It seems that the fact that within guest it's implemented using a bounce > buffer and that it's easiest to do by switching virtio to use the DMA API > isn't something virtio spec concerns itself with. Right, this is my reasoning as well. See this other (long) email I just sent to Christoph to explain the whole flow. > I'm open to suggestions. Cheers, Ben.
Re: [PATCH 2/2] powerpc/cpu: post the event cpux add/remove instead of online/offline during hotplug
On Sat, Aug 4, 2018 at 10:48 AM Michael Ellerman wrote: > > Hi Pingfan, > > Pingfan Liu writes: > > Technically speaking, echo 1/0 > cpuX/online is only a subset of cpu > > hotplug/unplug, i.e. add/remove. The latter one includes the physical > > adding/removing of a cpu device. Some user space tools such as kexec-tools > > resort to the event add/remove to automatically rebuild dtb. > > If the dtb is not rebuilt correctly, we may hang on 2nd kernel due to > > lack the info of boot-cpu-hwid in dtb. > > I notice you also sent a patch for ppc64_cpu to deal with CPUs being > removed rather than just offlined. > > If I apply this patch then existing ppc64_cpu (without your other patch) > will break. Is that right? > Yes. Since removing cpu will make a hole in cpu map, but ppc64_cpu code takes the assumption that the cpu map is contiguous. Thanks, Pingfan
Re: [RFC 0/4] Virtio uses DMA API for all devices
On Sun, 2018-08-05 at 03:22 +0300, Michael S. Tsirkin wrote: > I see the allure of this, but I think down the road you will > discover passing a flag in libvirt XML saying > "please use a secure mode" or whatever is a good idea. > > Even thought it is probably not required to address this > specific issue. > > For example, I don't think ballooning works in secure mode, > you will be able to teach libvirt not to try to add a > balloon to the guest. Right, we'll need some quirk to disable balloons in the guest I suppose. Passing something from libvirt is cumbersome because the end user may not even need to know about secure VMs. There are use cases where the security is a contract down to some special application running inside the secure VM, the sysadmin knows nothing about. Also there's repercussions all the way to admin tools, web UIs etc... so it's fairly wide ranging. So as long as we only need to quirk a couple of devices, it's much better contained that way. > > Later on, (we may have even already run Linux at that point, > > unsecurely, as we can use Linux as a bootloader under some > > circumstances), we start a "secure image". > > > > This is a kernel zImage that includes a "ticket" that has the > > appropriate signature etc... so that when that kernel starts, it can > > authenticate with the ultravisor, be verified (along with its ramdisk) > > etc... and copied (by the UV) into secure memory & run from there. > > > > At that point, the hypervisor is informed that the VM has become > > secure. > > > > So at that point, we could exit to qemu to inform it of the change, > > That's probably a good idea too. We probably will have to tell qemu eventually for migration, as we'll need some kind of key exchange phase etc... to deal with the crypto aspects (the actual page copy is sorted via encrypting the secure pages back to normal pages in qemu, but we'll need extra metadata). > > and > > have it walk the qtree and "Switch" all the virtio devices to use the > > IOMMU I suppose, but it feels a lot grosser to me. > > That part feels gross, yes. > > > That's the only other option I can think of. > > > > > However in this specific case, the flag does not need to come from the > > > hypervisor, it can be set by arch boot code I think. > > > Christoph do you see a problem with that? > > > > The above could do that yes. Another approach would be to do it from a > > small virtio "quirk" that pokes a bit in the device to force it to > > iommu mode when it detects that we are running in a secure VM. That's a > > bit warty on the virito side but probably not as much as having a qemu > > one that walks of the virtio devices to change how they behave. > > > > What do you reckon ? > > I think you are right that for the dma limit the hypervisor doesn't seem > to need to know. It's not just a limit mind you. It's a range, at least if we allocate just a single pool of insecure pages. swiotlb feels like a better option for us. > > What we want to avoid is to expose any of this to the *end user* or > > libvirt or any other higher level of the management stack. We really > > want that stuff to remain contained between the VM itself, KVM and > > maybe qemu. > > > > We will need some other qemu changes for migration so that's ok. But > > the minute you start touching libvirt and the higher levels it becomes > > a nightmare. > > > > Cheers, > > Ben. > > I don't believe you'll be able to avoid that entirely. The split between > libvirt and qemu is more about community than about code, random bits of > functionality tend to land on random sides of that fence. Better add a > tag in domain XML early is my advice. Having said that, it's your > hypervisor. I'm just suggesting that when hypervisor does somehow need > to care then I suspect most people won't be receptive to the argument > that changing libvirt is a nightmare. It only needs to care at runtime. The problem isn't changing libvirt per-se, I don't have a problem with that. The problem is that it means creating two categories of machines "secure" and "non-secure", which is end-user visible, and thus has to be escalated to all the various management stacks, UIs, etc... out there. In addition, there are some cases where the individual creating the VMs may not have any idea that they are secure. But yes, if we have to, we'll do it. However, so far, we don't think it's a great idea. Cheers, Ben. > > > > > To get swiotlb you'll need to then use the DT/ACPI > > > > > dma-range property to limit the addressable range, and a swiotlb > > > > > capable plaform will use swiotlb automatically. > > > > > > > > This cannot be done as you describe it. > > > > > > > > The VM is created as a *normal* VM. The DT stuff is generated by qemu > > > > at a point where it has *no idea* that the VM will later become secure > > > > and thus will have to restrict which pages can be used for "DMA". > > > > > > > > The VM will *at runtime* turn itself into a secure V