All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Oleksandr Andrushchenko <andr2000@gmail.com>,
	xen-devel@lists.xenproject.org
Cc: sstabellini@kernel.org, iwj@xenproject.org,
	bertrand.marquis@arm.com, rahul.singh@arm.com,
	Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Subject: Re: [PATCH] xen/arm: fix SBDF calculation for vPCI MMIO handlers
Date: Wed, 27 Oct 2021 18:35:50 +0100	[thread overview]
Message-ID: <cb7e9ef7-476e-93c3-d3c9-9a9ebc61003d@xen.org> (raw)
In-Reply-To: <20211027082533.1406015-1-andr2000@gmail.com>

Hi Oleksandr,

On 27/10/2021 09:25, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> 
> While in vPCI MMIO trap handlers for the guest PCI host bridge it is not
> enough for SBDF translation to simply call VPCI_ECAM_BDF(info->gpa) as
> the base address may not be aligned in the way that the translation
> always work. If not adjusted with respect to the base address it may not be
> able to properly convert SBDF and crashes:
> 
> (XEN) vpci_mmio_read 0000:65:1a.0 reg 8bc gpa e65d08bc

I can't find a printk() that may output this message. Where does this 
comes from?

Anyway, IIUC the guest physical address is 0xe65d08bc which, if I am not 
mistaken, doesn't belong to the range advertised for GUEST_VPCI_ECAM.

IMHO, the stack trace should come from usptream Xen or need some 
information to explain how this was reproduced.

> (XEN) Data Abort Trap. Syndrome=0x6
> (XEN) Walking Hypervisor VA 0x467a28bc on CPU0 via TTBR 0x00000000481d5000
I can understnad that if we don't substract GUEST_VPCI_ECAM, we would 
(in theory) not get the correct BDF. But... I don't understand how this 
would result to a data abort in the hypervisor.

In fact, I think the vPCI code should be resilient enough to not crash 
if we pass the wrong BDF.

When there is a data abort in Xen, you should get a stack trace from 
where this comes from. Can you paste it here?

> 
> Fix this by adjusting the gpa with respect to the host bridge base address
> in a way as it is done for x86.
> 
> Fixes: d59168dc05a5 ("xen/arm: Enable the existing x86 virtual PCI support for ARM")
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> ---
>   xen/arch/arm/vpci.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
> index 8f40a0dec6d2..23f45386f4b3 100644
> --- a/xen/arch/arm/vpci.c
> +++ b/xen/arch/arm/vpci.c
> @@ -24,7 +24,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
>       unsigned long data;
>   
>       /* We ignore segment part and always handle segment 0 */
> -    sbdf.sbdf = VPCI_ECAM_BDF(info->gpa);
> +    sbdf.sbdf = VPCI_ECAM_BDF(info->gpa - GUEST_VPCI_ECAM_BASE);

Looking at the rest of the rest, it seems that
  1) the issue is latent as the bits 0-27 are clear
  2) this will need to be modified to take into account dom0.

So I would prefer if the base address is passed differently (maybe in 
priv?) from the start. This will avoid extra modification that you 
already plan to have in a follow-up series.

>   
>       if ( vpci_ecam_read(sbdf, ECAM_REG_OFFSET(info->gpa),
>                           1U << info->dabt.size, &data) )
> @@ -44,7 +44,7 @@ static int vpci_mmio_write(struct vcpu *v, mmio_info_t *info,
>       pci_sbdf_t sbdf;
>   
>       /* We ignore segment part and always handle segment 0 */
> -    sbdf.sbdf = VPCI_ECAM_BDF(info->gpa);
> +    sbdf.sbdf = VPCI_ECAM_BDF(info->gpa - GUEST_VPCI_ECAM_BASE);
>   
>       return vpci_ecam_write(sbdf, ECAM_REG_OFFSET(info->gpa),
>                              1U << info->dabt.size, r);
> 

Cheers,

-- 
Julien Grall


  parent reply	other threads:[~2021-10-27 17:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27  8:25 [PATCH] xen/arm: fix SBDF calculation for vPCI MMIO handlers Oleksandr Andrushchenko
2021-10-27  8:59 ` Roger Pau Monné
2021-10-27  9:04   ` Oleksandr Andrushchenko
2021-10-27  9:23     ` Roger Pau Monné
2021-10-27  9:46       ` Oleksandr Andrushchenko
2021-10-27 17:07     ` Ian Jackson
2021-11-01 10:25       ` [PATCH] xen/arm: fix SBDF calculation for vPCI MMIO handlers [and 2 more messages] Ian Jackson
2021-11-01 21:06         ` Stefano Stabellini
2021-11-02  7:16           ` Oleksandr Andrushchenko
2021-11-02  9:32             ` Julien Grall
2021-11-02 11:21               ` Oleksandr Andrushchenko
2021-11-02 15:55           ` Ian Jackson
2021-10-27 17:35 ` Julien Grall [this message]
2021-10-28 12:09   ` [PATCH] xen/arm: fix SBDF calculation for vPCI MMIO handlers Oleksandr Andrushchenko
2021-10-28 13:22     ` Julien Grall
2021-10-28 14:16       ` Oleksandr Andrushchenko
2021-10-28 14:28         ` Julien Grall
2021-10-28 15:27           ` Oleksandr Andrushchenko
2021-10-28 15:35             ` Julien Grall
2021-10-28 15:54               ` Ian Jackson
2021-10-29  9:15                 ` Julien Grall
2021-10-28 18:00               ` Oleksandr Andrushchenko
2021-10-28 13:36     ` Roger Pau Monné
2021-10-28 14:23       ` Oleksandr Andrushchenko
2021-10-28 16:03         ` Roger Pau Monné
2021-10-28 17:55           ` Oleksandr Andrushchenko
2021-10-29  7:33             ` Roger Pau Monné
2021-11-01  6:14               ` Oleksandr Andrushchenko
2021-11-02  7:37                 ` Wei Chen
2021-11-02  7:46                   ` Oleksandr Andrushchenko
2021-11-02  8:12                     ` Wei Chen
2021-11-02  8:48                 ` Roger Pau Monné
2021-11-02  9:07                   ` Oleksandr Andrushchenko
2021-11-02  9:32                     ` Roger Pau Monné

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=cb7e9ef7-476e-93c3-d3c9-9a9ebc61003d@xen.org \
    --to=julien@xen.org \
    --cc=andr2000@gmail.com \
    --cc=bertrand.marquis@arm.com \
    --cc=iwj@xenproject.org \
    --cc=oleksandr_andrushchenko@epam.com \
    --cc=rahul.singh@arm.com \
    --cc=sstabellini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.