From: Juergen Gross <jgross@suse.com>
To: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@epam.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Stefano Stabellini <sstabellini@kernel.org>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 3/3] xen/virtio: enable grant based virtio on x86
Date: Fri, 7 Oct 2022 06:31:34 +0200 [thread overview]
Message-ID: <4d2af823-072c-8d08-8fa0-a223fd29b7d5@suse.com> (raw)
In-Reply-To: <2e721170-6035-90e3-f929-79b0a07e1891@epam.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 3315 bytes --]
On 06.10.22 18:04, Oleksandr Tyshchenko wrote:
>
> On 06.10.22 10:15, Juergen Gross wrote:
>
>
> Hello Juergen
>
>> Use an x86-specific virtio_check_mem_acc_cb() for Xen in order to setup
>> the correct DMA ops.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> arch/x86/xen/enlighten_hvm.c | 2 +-
>> arch/x86/xen/enlighten_pv.c | 2 +-
>> drivers/xen/grant-dma-ops.c | 10 ++++++++++
>> include/xen/xen-ops.h | 1 +
>> 4 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
>> index 1c1ac418484b..c1cd28e915a3 100644
>> --- a/arch/x86/xen/enlighten_hvm.c
>> +++ b/arch/x86/xen/enlighten_hvm.c
>> @@ -212,7 +212,7 @@ static void __init xen_hvm_guest_init(void)
>> return;
>>
>> if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
>> - virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
>> + virtio_set_mem_acc_cb(xen_virtio_restricted_mem_acc);
>>
>> init_hvm_pv_info();
>>
>> diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
>> index 9b1a58dda935..45b24c1b646a 100644
>> --- a/arch/x86/xen/enlighten_pv.c
>> +++ b/arch/x86/xen/enlighten_pv.c
>> @@ -112,7 +112,7 @@ static void __init xen_pv_init_platform(void)
>> {
>> /* PV guests can't operate virtio devices without grants. */
>> if (IS_ENABLED(CONFIG_XEN_VIRTIO))
>> - virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
>> + virtio_set_mem_acc_cb(xen_virtio_restricted_mem_acc);
>>
>> populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
>>
>> diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c
>> index a00112235877..60a7acc334ed 100644
>> --- a/drivers/xen/grant-dma-ops.c
>> +++ b/drivers/xen/grant-dma-ops.c
>> @@ -372,6 +372,16 @@ void xen_grant_setup_dma_ops(struct device *dev)
>> dev_err(dev, "Cannot set up Xen grant DMA ops, retain platform DMA ops\n");
>> }
>>
>> +bool xen_virtio_restricted_mem_acc(struct virtio_device *dev)
>> +{
>> + bool ret = xen_virtio_mem_acc(dev);
>
>
> The grant usage is mandatory for PV guests, right?
>
> Then xen_virtio_mem_acc() should always return true for PV guests (I
> mean even if CONFIG_XEN_VIRTIO_FORCE_GRANT is not set).
Yes.
>
>
>
>> +
>> + if (ret)
>> + xen_grant_setup_dma_ops(dev->dev.parent);
>> +
>> + return ret;
>> +}
>> +
>> MODULE_DESCRIPTION("Xen grant DMA-mapping layer");
>> MODULE_AUTHOR("Juergen Gross <jgross@suse.com>");
>> MODULE_LICENSE("GPL");
>> diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
>> index dae0f350c678..3dd5aa936f1d 100644
>> --- a/include/xen/xen-ops.h
>> +++ b/include/xen/xen-ops.h
>> @@ -219,6 +219,7 @@ static inline void xen_preemptible_hcall_end(void) { }
>> void xen_grant_setup_dma_ops(struct device *dev);
>> bool xen_is_grant_dma_device(struct device *dev);
>> bool xen_virtio_mem_acc(struct virtio_device *dev);
>> +bool xen_virtio_restricted_mem_acc(struct virtio_device *dev);
>> #else
>> static inline void xen_grant_setup_dma_ops(struct device *dev)
>> {
>
>
> And probably static inline stub always returning false if
> CONFIG_XEN_GRANT_DMA_OPS is not set.
Indeed.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
prev parent reply other threads:[~2022-10-07 4:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-06 7:14 [PATCH 0/3] xen/virtio: support " Juergen Gross
2022-10-06 7:14 ` [PATCH 1/3] xen/virtio: restructure xen grant dma setup Juergen Gross
2022-10-06 16:35 ` Oleksandr Tyshchenko
2022-10-07 0:23 ` Stefano Stabellini
2022-10-07 4:35 ` Juergen Gross
2022-10-06 7:14 ` [PATCH 2/3] xen/virtio: use dom0 as default backend for CONFIG_XEN_VIRTIO_FORCE_GRANT Juergen Gross
2022-10-06 17:23 ` Oleksandr Tyshchenko
2022-10-07 0:23 ` Stefano Stabellini
2022-10-06 7:15 ` [PATCH 3/3] xen/virtio: enable grant based virtio on x86 Juergen Gross
2022-10-06 16:04 ` Oleksandr Tyshchenko
2022-10-07 4:31 ` Juergen Gross [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4d2af823-072c-8d08-8fa0-a223fd29b7d5@suse.com \
--to=jgross@suse.com \
--cc=Oleksandr_Tyshchenko@epam.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sstabellini@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®