[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v18 2/2] xen/arm: check read handler behavior


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 1 Apr 2025 15:50:44 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=78rzobEEHDiCGVLMc8M5TlNFbWs0btjXkBRBmrKoM3U=; b=B4ydmfrCI60LwRIXaXZaz/Q7CyUzBzFuB0EZJ6AHyKtOMQi/oIVTuVPm7hKJj8CkID/b9fwTVAuonqIINO9gUFh7rGtW45iVQk9BDArqlpFjDxoTLFi2Um+EPFP+DOrCYgN9O67Kw/ONETkz4bRgE9N7fZGa5fHrxnjl4l8V/X5OvE04/yLWL1sMXng5y6jtq6Pz+rEbU6ssJYnnGES5K6UXEMkH3Knrp3r32S/2yfB/Rvb0OVLlwm3EbiXZa2TfV4uVf45hRMKmzun7rdOcXmCtFwrELLWkP6BB4xYRLEyfrec50DBvB++PoPV9FwuR1p+lyEAiw6CgJmkeE4iIjg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A52KvFicwJiha5U+m7c55RZhVdCDvY4WyReusIlVDHt9kvLB0ynIFGwmgkGH7qyPK9Qblv49rf9ldzh7CV2Xxewd30l69eKHddmA7xO9FD6/ZkFM6cnsZw+runUFiFoso0fO3C5DvUz2CbLEyM5GW6YQpLSl81GHykwPnmt7bVUoI20r1g3y6aGrXRsCU45Q5ymOSbnC1h8zQL2HkpOZEC3rXI3tpV4hF0YAL66vMkt0Ghdk5Xh1PwZLn3UO3raJ+1/nY9Gj4ozzHKEcCTk7AX9eo/CsWmtDlHih7UphMNGSwI8WUZf04YB8xgXnc4RDdXU/SUgO4RBweBbtyF9jvQ==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 01 Apr 2025 19:51:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 3/30/25 18:08, Julien Grall wrote:
> Hi Steward,
> 
> On 25/03/2025 17:27, Stewart Hildebrand wrote:
>> We expect mmio read handlers to leave the bits above the access size
>> zeroed. Add an ASSERT to check this aspect of read handler behavior.
>>
>> Suggested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
> 
> With one question below:
> 
> Acked-by: Julien Grall <jgrall@xxxxxxxxxx>

Thanks!

>> ---
>> v17->v18:
>> * no change
>>
>> v16->v17:
>> * new patch
>>
>> See 
>> https://lore.kernel.org/xen-devel/bc6660ef-59f1-4514-9792-067d987e3fbc@xxxxxxx/
>>
>> Also see 7db7bd0f319f ("arm/vpci: honor access size when returning an error")
>>
>> Also see xen/arch/arm/ioreq.c:handle_ioserv()
>> ---
>>   xen/arch/arm/io.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
>> index 653428e16c1f..68b5dca70026 100644
>> --- a/xen/arch/arm/io.c
>> +++ b/xen/arch/arm/io.c
>> @@ -37,6 +37,8 @@ static enum io_state handle_read(const struct mmio_handler 
>> *handler,
>>       if ( !handler->ops->read(v, info, &r, handler->priv) )
>>           return IO_ABORT;
>>   +    ASSERT((r & ~GENMASK_ULL((1U << info->dabt.size) * 8 - 1, 0)) == 0);
> 
> OOI, I was expecing GENMASK to be sufficient because "r" is effectively an 
> "unsigned long". So any reason to use GENMASK_ULL?

Only reason was that I took inspiration from Roger's suggestion at [1].
However, I agree that GENMASK is indeed sufficient. Feel free to fix up
on commit. Lastly, this is OK to commit out of order as there is no
dependency on the first patch.

[1] https://lore.kernel.org/xen-devel/Zk72jPtd9iXhChbc@macbook/



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.