[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 30/40] spapr-iommu: Always advertise the maximum poss
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 30/40] spapr-iommu: Always advertise the maximum possible DMA window size |
Date: |
Fri, 21 Dec 2018 16:45:56 +1100 |
From: Alexey Kardashevskiy <address@hidden>
When deciding about the huge DMA window, the typical Linux pseries guest
uses the maximum allowed RAM size as the upper limit. We did the same
on QEMU side to match that logic. Now we are going to support a GPU RAM
pass through which is not available at the guest boot time as it requires
the guest driver interaction. As the result, the guest requests a smaller
window than it should. Therefore the guest needs to be patched to
understand this new memory and so does QEMU.
Instead of reimplementing here whatever solution we choose for the guest,
this advertises the biggest possible window size limited by 32 bit
(as defined by LoPAPR). Since the window size has to be power-of-two
(the create rtas call receives a window shift, not a size),
this uses 0x8000.0000 as the maximum number of TCEs possible (rather than
32bit maximum of 0xffff.ffff).
This is safe as:
1. The guest visible emulated table is allocated in KVM (actual pages
are allocated in page fault handler) and QEMU (actual pages are allocated
when updated);
2. The hardware table (and corresponding userspace address table)
supports sparse allocation and also checks for locked_vm limit so
it is unable to cause the host any damage.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_rtas_ddw.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/hw/ppc/spapr_rtas_ddw.c b/hw/ppc/spapr_rtas_ddw.c
index 329feb148f..cb8a410359 100644
--- a/hw/ppc/spapr_rtas_ddw.c
+++ b/hw/ppc/spapr_rtas_ddw.c
@@ -96,9 +96,8 @@ static void rtas_ibm_query_pe_dma_window(PowerPCCPU *cpu,
uint32_t nret, target_ulong rets)
{
sPAPRPHBState *sphb;
- uint64_t buid, max_window_size;
+ uint64_t buid;
uint32_t avail, addr, pgmask = 0;
- MachineState *machine = MACHINE(spapr);
if ((nargs != 3) || (nret != 5)) {
goto param_error_exit;
@@ -114,27 +113,15 @@ static void rtas_ibm_query_pe_dma_window(PowerPCCPU *cpu,
/* Translate page mask to LoPAPR format */
pgmask = spapr_page_mask_to_query_mask(sphb->page_size_mask);
- /*
- * This is "Largest contiguous block of TCEs allocated specifically
- * for (that is, are reserved for) this PE".
- * Return the maximum number as maximum supported RAM size was in 4K pages.
- */
- if (machine->ram_size == machine->maxram_size) {
- max_window_size = machine->ram_size;
- } else {
- max_window_size = machine->device_memory->base +
- memory_region_size(&machine->device_memory->mr);
- }
-
avail = SPAPR_PCI_DMA_MAX_WINDOWS - spapr_phb_get_active_win_num(sphb);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
rtas_st(rets, 1, avail);
- rtas_st(rets, 2, max_window_size >> SPAPR_TCE_PAGE_SHIFT);
+ rtas_st(rets, 2, 0x80000000); /* The largest window we can possibly have */
rtas_st(rets, 3, pgmask);
rtas_st(rets, 4, 0); /* DMA migration mask, not supported */
- trace_spapr_iommu_ddw_query(buid, addr, avail, max_window_size, pgmask);
+ trace_spapr_iommu_ddw_query(buid, addr, avail, 0x80000000, pgmask);
return;
param_error_exit:
--
2.19.2
- [Qemu-devel] [PULL 24/40] ppc/xive: add support for the END Event State Buffers, (continued)
- [Qemu-devel] [PULL 24/40] ppc/xive: add support for the END Event State Buffers, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 19/40] ppc/xive: introduce the XIVE Event Notification Descriptors, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 21/40] spapr: introduce a spapr_irq_init() routine, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 34/40] spapr: allocate the interrupt thread context under the CPU core, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 26/40] ppc/xive: introduce a simplified XIVE presenter, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 25/40] ppc/xive: introduce the XIVE interrupt thread context, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 29/40] spapr/xive: use the VCPU id as a NVT identifier, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 27/40] ppc/xive: notify the CPU when the interrupt priority is more privileged, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 28/40] spapr/xive: introduce a XIVE interrupt controller, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 32/40] spapr: add hcalls support for the XIVE exploitation interrupt mode, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 30/40] spapr-iommu: Always advertise the maximum possible DMA window size,
David Gibson <=
- [Qemu-devel] [PULL 33/40] spapr: add device tree support for the XIVE exploitation mode, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 31/40] spapr: introduce a new machine IRQ backend for XIVE, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 36/40] spapr: add a 'reset' method to the sPAPR IRQ backend, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 40/40] MAINTAINERS: PPC: add a XIVE section, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 37/40] spapr: add an extra OV5 field to the sPAPR IRQ backend, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 38/40] spapr: introduce an 'ic-mode' machine option, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 39/40] spapr: change default CPU type to POWER9, David Gibson, 2018/12/21
- [Qemu-devel] [PULL 35/40] spapr: extend the sPAPR IRQ backend for XICS migration, David Gibson, 2018/12/21
- Re: [Qemu-devel] [PULL 00/40] ppc-for-4.0 queue 20181221, Peter Maydell, 2018/12/21
- Re: [Qemu-devel] [PULL 00/40] ppc-for-4.0 queue 20181221, no-reply, 2018/12/26