lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SA1PR21MB1335CDC53B8B4B03838CD335BF6B9@SA1PR21MB1335.namprd21.prod.outlook.com>
Date:   Tue, 16 Aug 2022 21:14:17 +0000
From:   Dexuan Cui <decui@...rosoft.com>
To:     Jeffrey Hugo <quic_jhugo@...cinc.com>,
        "wei.liu@...nel.org" <wei.liu@...nel.org>,
        KY Srinivasan <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        "lpieralisi@...nel.org" <lpieralisi@...nel.org>,
        "bhelgaas@...gle.com" <bhelgaas@...gle.com>,
        "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
        "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Michael Kelley (LINUX)" <mikelley@...rosoft.com>,
        "robh@...nel.org" <robh@...nel.org>, "kw@...ux.com" <kw@...ux.com>,
        "helgaas@...nel.org" <helgaas@...nel.org>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
        "boqun.feng@...il.com" <boqun.feng@...il.com>,
        Boqun Feng <Boqun.Feng@...rosoft.com>
CC:     Carl Vanderlip <quic_carlv@...cinc.com>
Subject: RE: [PATCH] PCI: hv: Fix the definiton of vector in
 hv_compose_msi_msg()

> From: Jeffrey Hugo <quic_jhugo@...cinc.com>
> Sent: Tuesday, August 16, 2022 9:01 AM
> > ...
> > @@ -1702,7 +1702,8 @@ static void hv_compose_msi_msg(struct irq_data
> *data, struct msi_msg *msg)
> >   	struct tran_int_desc *int_desc;
> >   	struct msi_desc *msi_desc;
> >   	bool multi_msi;
> > -	u8 vector, vector_count;
> > +	u32 vector; /* Must be u32: see the struct hv_msi_desc3 */
> 
> Don't you need to cast this down to a u8 for v1 and v2?
> Feels like this should be generating a compiler warning...

My gcc 9.4.0 didn't generate a warning.

hv_compose_msi_req_v3() is for both ARM64 and x86. In the case of ARM64
the 'vector' can be a u32 integer according to the comment around struct 
hv_msi_desc3.

hv_compose_msi_req_v1 and v2 are for x86 only, and the 'vector' can't be
longer than u8. I can post a v2 with the extra changes below:


diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 53580899c859..c7fd76bc8b4c 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1703,7 +1703,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
        struct msi_desc *msi_desc;
        bool multi_msi;
        u32 vector; /* Must be u32: see the struct hv_msi_desc3 */
-       u16 vector_count;
+       u16 vector_count; /* see hv_msi_desc, hv_msi_desc2 and hv_msi_desc3 */
        struct {
                struct pci_packet pci_pkt;
                union {
@@ -1788,12 +1788,17 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
        ctxt.pci_pkt.completion_func = hv_pci_compose_compl;
        ctxt.pci_pkt.compl_ctxt = &comp;

+       /*
+        * hv_compose_msi_req_v1 and v2 are for x86 only, meaning 'vector'
+        * can't be longer than u8. Cast 'vector' down to u8 explicitly for
+        * better readability.
+        */
        switch (hbus->protocol_version) {
        case PCI_PROTOCOL_VERSION_1_1:
                size = hv_compose_msi_req_v1(&ctxt.int_pkts.v1,
                                        dest,
                                        hpdev->desc.win_slot.slot,
-                                       vector,
+                                       (u8)vector,
                                        vector_count);
                break;

@@ -1802,7 +1807,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
                size = hv_compose_msi_req_v2(&ctxt.int_pkts.v2,
                                        dest,
                                        hpdev->desc.win_slot.slot,
-                                       vector,
+                                       (u8)vector,
                                        vector_count);
                break;


Thanks,
-- Dexuan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ