[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] fix host-endianness bug
From: |
Peter Maydell |
Subject: |
Re: [PATCH] fix host-endianness bug |
Date: |
Thu, 25 Apr 2024 10:26:18 +0100 |
On Wed, 24 Apr 2024 at 19:13, Alexandra Diupina <adiupina@astralinux.ru> wrote:
>
> Add a function xlnx_dpdma_read_descriptor() that
> combines reading the descriptor from desc_addr
> by calling dma_memory_read() and swapping desc
> fields from guest memory order to host memory order.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: d3c6369a96 ("introduce xlnx-dpdma")
> Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
> ---
> hw/dma/xlnx_dpdma.c | 38 +++++++++++++++++++++++++++++++++-----
> 1 file changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
> index 1f5cd64ed1..5fd4e31699 100644
> --- a/hw/dma/xlnx_dpdma.c
> +++ b/hw/dma/xlnx_dpdma.c
> @@ -614,6 +614,38 @@ static void xlnx_dpdma_register_types(void)
> type_register_static(&xlnx_dpdma_info);
> }
>
> +static MemTxResult xlnx_dpdma_read_descriptor(XlnxDPDMAState *s, uint8_t
> channel,
> + uint64_t desc_addr, DPDMADescriptor
> *desc)
> +{
> + if (dma_memory_read(&address_space_memory, desc_addr, &desc,
> + sizeof(DPDMADescriptor),
> MEMTXATTRS_UNSPECIFIED)) {
> + s->registers[DPDMA_EISR] |= ((1 << 1) << channel);
> + xlnx_dpdma_update_irq(s);
> + s->operation_finished[channel] = true;
I think these three lines in the if() here should remain at the callsite --
although we only have one place that reads a descriptor at the
moment, different callers might in theory handle the descriptor-read
failure differently.
> + return MEMTX_ERROR;
Otherwise this looks good; thanks.
-- PMM
- [PATCH RFC] prevent overflow in xlnx_dpdma_desc_get_source_address(), Alexandra Diupina, 2024/04/12
- Re: [PATCH RFC] prevent overflow in xlnx_dpdma_desc_get_source_address(), Peter Maydell, 2024/04/12
- Re: [PATCH RFC] prevent overflow in xlnx_dpdma_desc_get_source_address(), Alexandra Diupina, 2024/04/16
- RE: [PATCH RFC] prevent overflow in xlnx_dpdma_desc_get_source_address(), Konrad, Frederic, 2024/04/17
- Re: [PATCH RFC] prevent overflow in xlnx_dpdma_desc_get_source_address(), Alexandra Diupina, 2024/04/23
- Re: [PATCH RFC] prevent overflow in xlnx_dpdma_desc_get_source_address(), Peter Maydell, 2024/04/23
- [PATCH v2 RFC] fix host-endianness bug and prevent overflow, Alexandra Diupina, 2024/04/24
- Re: [PATCH v2 RFC] fix host-endianness bug and prevent overflow, Peter Maydell, 2024/04/24
- [PATCH] fix host-endianness bug, Alexandra Diupina, 2024/04/24
- Re: [PATCH] fix host-endianness bug,
Peter Maydell <=
- [PATCH v2] fix host-endianness bug, Alexandra Diupina, 2024/04/25
- Re: [PATCH v2] fix host-endianness bug, Philippe Mathieu-Daudé, 2024/04/25
- [PATCH v3] fix endianness bug, Alexandra Diupina, 2024/04/25
- Re: [PATCH v3] fix endianness bug, Richard Henderson, 2024/04/25
- [PATCH] fix bit fields extraction and prevent overflow, Alexandra Diupina, 2024/04/24
- Re: [PATCH] fix bit fields extraction and prevent overflow, Peter Maydell, 2024/04/25