> From: Jeffrey Hugo <quic_jhugo@xxxxxxxxxxx> > 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 = ∁ + /* + * 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