[RFC PATCH v3 07/38] xen-platform: allow its creation with XEN_EMULATE mode

David Woodhouse posted 38 patches 3 years, 1 month ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony Perard <anthony.perard@citrix.com>, Paul Durrant <paul@xen.org>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Markus Armbruster <armbru@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
There is a newer version of this series
[RFC PATCH v3 07/38] xen-platform: allow its creation with XEN_EMULATE mode
Posted by David Woodhouse 3 years, 1 month ago
From: Joao Martins <joao.m.martins@oracle.com>

The only thing we need to handle on KVM side is to change the
pfn from R/W to R/O.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 hw/i386/xen/xen_platform.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index a6f0fb478a..15d5ae7c69 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -283,7 +283,10 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
     case 0: /* Platform flags */ {
         hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
             HVMMEM_ram_ro : HVMMEM_ram_rw;
-        if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
+        if (xen_mode == XEN_EMULATE) {
+            /* XXX */
+            s->flags = val & PFFLAG_ROM_LOCK;
+        } else if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
             DPRINTF("unable to change ro/rw state of ROM memory area!\n");
         } else {
             s->flags = val & PFFLAG_ROM_LOCK;
@@ -508,12 +511,6 @@ static void xen_platform_realize(PCIDevice *dev, Error **errp)
     PCIXenPlatformState *d = XEN_PLATFORM(dev);
     uint8_t *pci_conf;
 
-    /* Device will crash on reset if xen is not initialized */
-    if (!xen_enabled()) {
-        error_setg(errp, "xen-platform device requires the Xen accelerator");
-        return;
-    }
-
     pci_conf = dev->config;
 
     pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
-- 
2.35.3
Re: [RFC PATCH v3 07/38] xen-platform: allow its creation with XEN_EMULATE mode
Posted by Paul Durrant 3 years, 1 month ago
On 16/12/2022 00:40, David Woodhouse wrote:
> From: Joao Martins <joao.m.martins@oracle.com>
> 
> The only thing we need to handle on KVM side is to change the
> pfn from R/W to R/O.
> 
> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>   hw/i386/xen/xen_platform.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
> index a6f0fb478a..15d5ae7c69 100644
> --- a/hw/i386/xen/xen_platform.c
> +++ b/hw/i386/xen/xen_platform.c
> @@ -283,7 +283,10 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
>       case 0: /* Platform flags */ {
>           hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
>               HVMMEM_ram_ro : HVMMEM_ram_rw;
> -        if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
> +        if (xen_mode == XEN_EMULATE) {
> +            /* XXX */

???

Paul

> +            s->flags = val & PFFLAG_ROM_LOCK;
> +        } else if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
>               DPRINTF("unable to change ro/rw state of ROM memory area!\n");
>           } else {
>               s->flags = val & PFFLAG_ROM_LOCK;
> @@ -508,12 +511,6 @@ static void xen_platform_realize(PCIDevice *dev, Error **errp)
>       PCIXenPlatformState *d = XEN_PLATFORM(dev);
>       uint8_t *pci_conf;
>   
> -    /* Device will crash on reset if xen is not initialized */
> -    if (!xen_enabled()) {
> -        error_setg(errp, "xen-platform device requires the Xen accelerator");
> -        return;
> -    }
> -
>       pci_conf = dev->config;
>   
>       pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
Re: [RFC PATCH v3 07/38] xen-platform: allow its creation with XEN_EMULATE mode
Posted by David Woodhouse 3 years, 1 month ago

On 20 December 2022 16:19:54 GMT, Paul Durrant <xadimgnik@gmail.com> wrote:
>On 16/12/2022 00:40, David Woodhouse wrote:
>> From: Joao Martins <joao.m.martins@oracle.com>
>> 
>> The only thing we need to handle on KVM side is to change the
>> pfn from R/W to R/O.
>> 
>> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
>> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
>> ---
>>   hw/i386/xen/xen_platform.c | 11 ++++-------
>>   1 file changed, 4 insertions(+), 7 deletions(-)
>> 
>> diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
>> index a6f0fb478a..15d5ae7c69 100644
>> --- a/hw/i386/xen/xen_platform.c
>> +++ b/hw/i386/xen/xen_platform.c
>> @@ -283,7 +283,10 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t v
>>       case 0: /* Platform flags */ {
>>           hvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
>>               HVMMEM_ram_ro : HVMMEM_ram_rw;
>> -        if (xen_set_mem_type(xen_domid, mem_type, 0xc0, 0x40)) {
>> +        if (xen_mode == XEN_EMULATE) {
>> +            /* XXX */
>
>???

Needs to mess with the q35/i440gx pam_update() I think.