From nobody Fri Nov 29 10:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 164493885109954.25311225412304; Tue, 15 Feb 2022 07:27:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.273323.468463 (Exim 4.92) (envelope-from ) id 1nJzjS-0001qh-LD; Tue, 15 Feb 2022 15:27:10 +0000 Received: by outflank-mailman (output) from mailman id 273323.468463; Tue, 15 Feb 2022 15:27:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nJzjS-0001qa-IA; Tue, 15 Feb 2022 15:27:10 +0000 Received: by outflank-mailman (input) for mailman id 273323; Tue, 15 Feb 2022 15:27:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nJzjR-0001qG-67 for xen-devel@lists.xenproject.org; Tue, 15 Feb 2022 15:27:09 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id bc8d6a1d-8e73-11ec-b215-9bbe72dcb22c; Tue, 15 Feb 2022 16:27:08 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 545621396; Tue, 15 Feb 2022 07:27:07 -0800 (PST) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 609393F66F; Tue, 15 Feb 2022 07:27:06 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bc8d6a1d-8e73-11ec-b215-9bbe72dcb22c From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 2/3] xen/vpci: msix: change return value of vpci_msix_{read,write} Date: Tue, 15 Feb 2022 15:25:17 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1644938852694100013 Content-Type: text/plain; charset="utf-8" Return value is different for the MMIO handler on ARM and x86 architecture. To make the code common for both architectures change the return value of vpci_msix_{read, write} to bool. Architecture-specific return value will be handled in arch code. Signed-off-by: Rahul Singh --- Changes since v1: - Added in this version --- xen/arch/x86/hvm/vmsi.c | 10 ++++++++-- xen/drivers/vpci/msix.c | 24 ++++++++++++------------ xen/include/xen/vpci.h | 8 ++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c index 17426f238c..761ce674d7 100644 --- a/xen/arch/x86/hvm/vmsi.c +++ b/xen/arch/x86/hvm/vmsi.c @@ -1002,7 +1002,10 @@ static int x86_msix_write(struct vcpu *v, unsigned l= ong addr, unsigned int len, const struct domain *d =3D v->domain; struct vpci_msix *msix =3D vpci_msix_find(d, addr); =20 - return vpci_msix_write(msix, addr, len, data); + if( !vpci_msix_write(msix, addr, len, data) ) + return X86EMUL_RETRY; + + return X86EMUL_OKAY; } =20 static int x86_msix_read(struct vcpu *v, unsigned long addr, unsigned int = len, @@ -1011,7 +1014,10 @@ static int x86_msix_read(struct vcpu *v, unsigned lo= ng addr, unsigned int len, const struct domain *d =3D v->domain; struct vpci_msix *msix =3D vpci_msix_find(d, addr); =20 - return vpci_msix_read(msix, addr, len, data); + if ( !vpci_msix_read(msix, addr, len, data) ) + return X86EMUL_RETRY; + + return X86EMUL_OKAY; } =20 static const struct hvm_mmio_ops vpci_msix_table_ops =3D { diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c index d89396a3b4..5b315757ef 100644 --- a/xen/drivers/vpci/msix.c +++ b/xen/drivers/vpci/msix.c @@ -155,8 +155,8 @@ static struct vpci_msix_entry *get_entry(struct vpci_ms= ix *msix, return &msix->entries[(addr - start) / PCI_MSIX_ENTRY_SIZE]; } =20 -int vpci_msix_read(struct vpci_msix *msix, unsigned long addr, - unsigned int len, unsigned long *data) +bool vpci_msix_read(struct vpci_msix *msix, unsigned long addr, + unsigned int len, unsigned long *data) { const struct vpci_msix_entry *entry; unsigned int offset; @@ -164,10 +164,10 @@ int vpci_msix_read(struct vpci_msix *msix, unsigned l= ong addr, *data =3D ~0ul; =20 if ( !msix ) - return X86EMUL_RETRY; + return false; =20 if ( !access_allowed(msix->pdev, addr, len) ) - return X86EMUL_OKAY; + return true; =20 if ( VMSIX_ADDR_IN_RANGE(addr, msix->pdev->vpci, VPCI_MSIX_PBA) ) { @@ -193,7 +193,7 @@ int vpci_msix_read(struct vpci_msix *msix, unsigned lon= g addr, break; } =20 - return X86EMUL_OKAY; + return true; } =20 spin_lock(&msix->pdev->vpci->lock); @@ -227,21 +227,21 @@ int vpci_msix_read(struct vpci_msix *msix, unsigned l= ong addr, } spin_unlock(&msix->pdev->vpci->lock); =20 - return X86EMUL_OKAY; + return true; } =20 -int vpci_msix_write(struct vpci_msix *msix, unsigned long addr, - unsigned int len, unsigned long data) +bool vpci_msix_write(struct vpci_msix *msix, unsigned long addr, + unsigned int len, unsigned long data) { const struct domain *d =3D msix->pdev->domain; struct vpci_msix_entry *entry; unsigned int offset; =20 if ( !msix ) - return X86EMUL_RETRY; + return false; =20 if ( !access_allowed(msix->pdev, addr, len) ) - return X86EMUL_OKAY; + return true; =20 if ( VMSIX_ADDR_IN_RANGE(addr, msix->pdev->vpci, VPCI_MSIX_PBA) ) { @@ -264,7 +264,7 @@ int vpci_msix_write(struct vpci_msix *msix, unsigned lo= ng addr, } } =20 - return X86EMUL_OKAY; + return true; } =20 spin_lock(&msix->pdev->vpci->lock); @@ -342,7 +342,7 @@ int vpci_msix_write(struct vpci_msix *msix, unsigned lo= ng addr, } spin_unlock(&msix->pdev->vpci->lock); =20 - return X86EMUL_OKAY; + return true; } =20 static int init_msix(struct pci_dev *pdev) diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index 0381a2c911..1c36845abf 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -225,11 +225,11 @@ bool vpci_ecam_read(pci_sbdf_t sbdf, unsigned int reg= , unsigned int len, =20 void vpci_msix_arch_register(struct vpci_msix *msix, struct domain *d); =20 -int vpci_msix_write(struct vpci_msix *msix, unsigned long addr, - unsigned int len, unsigned long data); +bool vpci_msix_write(struct vpci_msix *msix, unsigned long addr, + unsigned int len, unsigned long data); =20 -int vpci_msix_read(struct vpci_msix *msix, unsigned long addr, - unsigned int len, unsigned long *data); +bool vpci_msix_read(struct vpci_msix *msix, unsigned long addr, + unsigned int len, unsigned long *data); =20 #endif /* __XEN__ */ =20 --=20 2.25.1