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

Re: [RFC PATCH 0/1] xen/arm: smccc: preserve arguments before register setup


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Jan Setje-Eilers <Jan.SetjeEilers@xxxxxxxxxx>
  • Date: Sat, 29 Aug 2026 15:00:48 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • 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=U1kG4myDpqbheIIqGkuoL+on0QP1GBAL358gjZKTDyo=; b=I7n+kALAc821Taxn3LQBcOBC5YQEOnY2RPPlaIrTsGIQ3G3616/i95nj1bZxZWOaVFli8NCx8VGADRLG+6u+2K2xB33yOqCpaKfhFlARFk4cQj4v/z7Z2Lmw5m27Gwtp9JNVzVxK/Gg/nFUx5V4VSyv3hkamu5BDKbc90DwZf+Ymp2SxqvJQozojDgDvEu8QgnjahY2orD1pLesD3mNinnkUvb4fcbSVI+EKDTyIXsi0DZu8o7oyGOUkuYnnrOARljOQ/sb2TFBLEBwm1KmjRPEIvnYMmOY+uzsGX0pxVhC+rTFpcyzXc/2wqOZghcVhqmWwjeqwvxJqbzIEDMf9fw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SrKzsBrk7IP1nh/ozNuSsMmg8HR3xPnXTcosFKzVYkCg2+6aGUOwP9tWdnGzJsRAwOey0UsK9zE3cQAjdFW5sRwsLD06FklCJdIii/6JbnnsYvix1nVyOm7h2NB+Q81YJlB9wPKU8hSYd+V17JfDBnatfOznIXXbJGRRNWaeNuxK2ZMP31aIPOIbtjIFsQHQoKb6F3/SzKi3XeKNtU+JLISAnvgbC+no8bQCObVkXRadF++KaVRVkA3qBCw4lvBspDjD6qweOk0J7omJ5y+OPUbBPUuDaGuNX989LwcvtStqYX7etdqoTmhmes3cmNMATUKJvtC8nQ7vRi54CXAFIQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=corp-2025-04-25 header.d=oracle.com header.i="@oracle.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=fail header.s=selector2-oracle-onmicrosoft-com header.d=oracle.onmicrosoft.com header.i="@oracle.onmicrosoft.com"
  • Autocrypt: addr=Jan.SetjeEilers@xxxxxxxxxx; keydata= xsDNBGetHhIBDACa4fBRw0+D/y8p0kzZyJ+K5pisnqCKCFVKtAhVYFJjzEoUvVtqKJpjZaWp JtlNQ05u3GZKofFptGJmXJZtttujfE6iWqjFVcm1SUo8kSRSLQ+AxtfAot319Do73k/uhfQM 71+cX5pO6EybCrr962npOEfe6yNbZ3UmszrbmRORw3aI9g/VHmC1SwFj3Gq0KHBQvEB89J6F iDgrHGnQVyQDmCBF6n6mqSJFV/fWK6XeGSj/T/R+8osU0FpXcsZ4OCY9eyJ23zY1M2f2VEV4 B61+UW8orqgXe3mADI0yLP0onViD2UHqV6EDjLWN1ukUkJUoPWzv65LyU1sAw0rKPELvcl4/ rzJPiO8FNMjTp4jibe46Spyh5BKYxN54m8zAF9D9uHA1IX9pJpNRS2uKEnZWHJx1Ew2GZINv 8VDhpPxJP4p4ArZMSzAsNKYSqyuXyQ8Fcn7DCwI8E4tl6tRNacBkf1ByF30oYFYFg1pbMIQm 4z9BY01cBMB59/50dy3QF3MAEQEAAc0tSmFuIFNldGplLUVpbGVycyA8SmFuLlNldGplRWls ZXJzQG9yYWNsZS5jb20+wsENBBMBCAA3FiEEvrH8dyNhbaVzmqUqqJoDwbaIAmsFAmetHhIF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YmRByC4W029 jE+4cS93yyFScwARAQABwsD8BBgBCAAmFiEEvrH8dyNhbaVzmqUqqJoDwbaIAmsFAmetHhIF CQWjmoACGwwACgkQqJoDwbaIAmvmZgv8DAZ8XQnunSonH0N5HMa9qaQafl07cfd8jVk4IFH9 UPIH0463s/0oVJV1hlcqqqk0nZKwobflIrehB/TSSaLnAoy9b2raOKNbj0ppZdoGCm+S3z67 O1c7cx8vQ+nnSe4E+Ko/J/8e4FOYhFUOc4lmIn4ByK+SBKitAkOYI64ugunvGZLj1TV+b1Wf wiWaJUGmzZkjIU2T6J8W1riYn1KW2uNheJQU4/sVtBc6j/hIqccTKBpx0qTszeZnFa28aGkg t2BXv2TqaA7yzbLymTRG4JHRlc9LQ2tHjIjkRBGXpiOG26S7JoeHz+QCqSK2XPp+LP5/XhTk Vvb8FjeyBuJ+Q5RK2vYk6Ws5ua4G1p2AUs0w5SpRxpLUTuTVlntyXQfp7Pa42oX364UOGNrY c+ddxSb+KW13sbIRslW8+LWdvNH/VgPKC3SkblSG5H/e3sfLsA3DAmu886allZ82imnPRlYH /epCCdHbjMyPhatWd4WT2RFakWMvkwGDSJUd50h8
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Joao Martins <joao.m.martins@xxxxxxxxxx>
  • Delivery-date: Sat, 29 Aug 2026 22:01:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 8/29/26 11:19, Andrew Cooper wrote:
> On 29/08/2026 5: 53 pm, Andrew Cooper wrote: > On 29/08/2026 3: 12 am,
> Jan Setje-Eilers wrote: >> Hi Andrew, >> >> While investigating an SMC
> forwarding failure after updating to Xen 4. 22, >> I found that firmware
> could
> 
> 
> On 29/08/2026 5:53 pm, Andrew Cooper wrote:
>> On 29/08/2026 3:12 am, Jan Setje-Eilers wrote:
>>> Hi Andrew,
>>>
>>> While investigating an SMC forwarding failure after updating to Xen 4.22,
>>> I found that firmware could receive different values from those passed to
>>> arm_smccc_1_1_smc().
>>>
>>> Several public Xen callers pass get_user_reg() calls directly to this
>>> helper.  This includes the SCMI, ZynqMP EEMI, and i.MX forwarding paths.
>>> The helper puts each value into its SMC argument register as the
>>> expression is evaluated.  A later get_user_reg() call can then overwrite a
>>> register prepared for an earlier argument.
>>>
>>> The change in generated code appears after:
>>>
>>> 67bcf5eae709 ("xen/arm: Simplify type handling for SMCCC declarations")
>>>
>>> I am not sure which behavior the helper is intended to provide. Should
>>> arm_smccc_1_1_smc() continue to accept arguments such as get_user_reg()
>>> calls, or should callers save those values in local variables first?
>>>
>>> The attached patch is a candidate for the first option. It restores
>>> temporary variables inside the helper, allowing all calls to finish before
>>> x0-x7 are prepared for the SMC instruction. I am not able to validate the
>>> public SCMI and ZynqMP paths on hardware, but their generated code now
>>> finishes every get_user_reg() call before the final register setup and
>>> smc. With this change, SMCs also work as intended on the device I'm
>>> using.
>>>
>>> If the intent is not to accept function calls as arguments, we should
>>> probably fix the SCMI, ZynqMP EEMI, and i.MX callers.
>>>
>>> Given the existing use cases, this seems like a bug, but your patch looks
>>> intentional. It's very possible I'm missing the intended design. I would
>>> appreciate your view on the intended contract.
>>>
>>> Thanks for any advice or help with this.
>> Yes you're right.  My change was buggy.   It was actually part of a
>> mutli-stage cleanup across several patches.
>>
>> I'll submit my own patch.  I'm afraid your AI has put in whitespace
>> errors where a straight revert would have gotten it correct, and left
>> the 0 case still buggy.

 Thank you!! Yes, a revert also makes sense.

 Heh, the bulk of my AI usage was actually to try to make sure I hit all
the project rules and formatting since I'm much less used to some of the
style here. Sigh. :)

> In fact there's another bug.  The SMCCC ABI states that certain
> registers are clobbered, yet these are missing from asm().
> 
> It's also sad that this macro maze goes to the effort of making a
> function-like-call which can return 4 registers by value, just to then
> force it all to be spilled to the stack anyway.

 The other way to do this, if we're actually trying to minimize
instructions,
would actually be to create another interface that does something like
get_user_reg() as part of the invocation. Then that could be a single
assembly implementation.

-jan



 


Rackspace

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