[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2.1 6.5/70] x86/kexec: Annotate embedded data with ELF metadata
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Thu, 17 Feb 2022 16:06:44 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ypmZqLLCvaipn6/0EIASn2jU1PCFp3n5XIdOL8ylKdQ=; b=MvllHHb8u27NuvAVx5f6gXMWrl3IT4tMwlqa170YnwM1tKYZvZW4vIh/Si/NduZu7TyEEXEk4TVHRMbTHUDUjmi2ir6sYjcV/c8jg7wmu+CbmNVr238I4UpiVa4oI6XcwvtlMUGNVOJVsIZNOUrg6EjGf0O39nDe4lUZ3QRziqrTbkLv5regdYNgEcdM+FAAVrrNpkm+dz++hRwX6q+eYS7lAdSnwTskkoLOQAfuu/SESrziZOGcWFix+c/aKj1rVqttSLGSwa4zhKABVR05zNQlbv2vMraeEykoEQIiixtn8vomcUXO5NI0dNCnXKyw/NgFLmjjQqDsBx8cIKLVqQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nMhuMzJVwavUTu+gFfH4hNxeQlYpaMkJrowBOsj06dubc5gmoXdy/ArspUKIFZdeRk++m/aKRtaopKEQ+V604tbgJ+uq5vH1hC9MgrlqMIGKld9vNLc2fxeresVqK7OBZaQ0cULIXKc/dCqEWPVZL9EY8XZ7QfsO+drxStJ84xJoiGhvH+NspWlPrwq9omSWWnnMJxNEZcM/4mZ2kHcyLXm4gOFharUExkrjziwvh7fyjkAIWPW6QxIgT/moDLe1/HAXLUpJcrTGvhr1oujcSlM3oiPn2dkCVeSp+O5A9VKc9aeM/XJnoYkZa3EpBTCiOOflmabRp9f0XhgiSuFK3A==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Thu, 17 Feb 2022 16:07:02 +0000
- Ironport-data: A9a23:DrNUNqPXb6yYzwTvrR1+kMFynXyQoLVcMsEvi/4bfWQNrUp032RUy mdOC2jUMq2LMWCkLdhwbYiwpEMG7ZKHy9JgTAto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6UUsxNbVU8En1500s8w7RRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYozLOvdN84 uRHj5WxcyYzErDpptYdcDANRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YsBqit4uM4/AO4QHt2s75TrYEewnUdbIRKCiCdpwgmtr2psSRq+2i 8wxNDhhYTLkZh51anAJGJ8jt9WVukDkSmgNwL6SjfVuuDWCpOBr65D9PdyQdtGUSMF9mkeDu nmA72n/GgsdNtGU1XyC6H3ErvDLtTP2XsQVDrLQ3vxgjUCXx2cTIAYLTlb9qv684nNSQPoGd RZSoHB36/Fvqgr7FbERQiFUvlaD+TwfVvBhGdcz6Tus0IbJxjirBkstG2sphMMdiOc6Qjkj1 1msltzvBCBy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encGHjWubqBJcK Z0k/A3wQZIDk5nCfhTaEN1PdTrlpnurtbLcBQGDxko5E2lljWz8oP3FBCew1M3Ty5P6a1Kyx mHryXJooGY992rwB7V0GHeq75MnsH699dFDMuQzuAINzTXjBqybogJYczBgNl1mpDr1L8Zqq iKn/4SBbU015oXRBDtnfLZ4Xil7N/p0Q679bbXuwq5nSWzfkNENyMIv/MmTvKe0Tt8gDg06t M644rS3aAnfC/ojWDz4cPFWAptkVfxqX0+kfQLh3gaSocGbqRNxLZvtn+9Pa1wVB4S0rpXW9 WGzfuskMp+YBefdTTUr2NvyNujUjA6GQqHWFELvoiQ3yJNlH50wkMEzIhH901wuK4VWt1B/a DJI65onLZBQosfar98Hv4IRY+yBnbWSRzBPWqOKRDsFb0BOXjKt5nriY9Fqd2CadgN1t8/iZ 7BWFRXuSo7fF/vE9SH2NlR/hXEUAyGLH3QIwFllu5EU5HHNcjW2By4OScTepGb0oYi6+XgKo OOBK4=
- Ironport-sdr: iM40Q1ZZXA+4pQJ9wfRrPuTg+kuY25QKWMn5iMU9CgiIvCa3nnXc3Si7k7FRjjaEY8IkiTke40 fy+JsGQRMPanOPwaMEyeOJkqFc0QFVOiw/yeOgdqPDmnMBOQhtBxmkF8SxVjo+HpRaFqYL9gkd e57lJLFTlaXRDLG7otOUfwOMrTQxVElRrpcvFTiIRrSFfMlV9X6/iw3EFFfJ0Aj8CCNRQ0l2y6 cJp6BFOtFl4A2J6VLZUjJM6Y4Z8+jpB4pmOcEX3Zd4gq68w7kMT3G3qKllggqKttSC9sSBJhn0 I6MyHGAcnU0/tSfFitmNpkrT
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYI+WIB3ag8ccQV0mMbUcu9Q8VKKyXjjSAgAAXo4CAAC0dgIAAFfaA
- Thread-topic: [PATCH v2.1 6.5/70] x86/kexec: Annotate embedded data with ELF metadata
On 17/02/2022 14:48, Jan Beulich wrote:
> On 17.02.2022 13:06, Andrew Cooper wrote:
>> On 17/02/2022 10:42, Jan Beulich wrote:
>>> On 17.02.2022 11:01, Andrew Cooper wrote:
>>>> Scanning for embedded endbranch instructions involves parsing the .text
>>>> disassembly. Data in the kexec trampoline has no ELF metadata, so objdump
>>>> treats it as instructions and tries to disassemble. Convert:
>>>>
>>>> ffff82d040396108 <compatibility_mode_far>:
>>> What about the (possible) padding ahead of this? Should the .align
>>> there perhaps specify a filler character?
>> What about it? It's just long nops like all other padding in .text
>>
>> ffff82d040396101: ff d5 call *%ebp
>> ffff82d040396103: 0f 0b ud2
>> ffff82d040396105: 0f 1f 00 nopl (%eax)
>>
>> ffff82d040396108 <compatibility_mode_far>:
>> ffff82d040396108: 00 00 00 00 10
>> 00 ......
>>
>> And for this problem, we don't need to care about the behaviour of any
>> pre-CET version of binutils.
> I was about to ask, but yes - this is a good point.
>
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
Thanks.
>>> It just so
>>> happens that there's no 4-byte gap between compat_mode_gdt_desc and
>>> compat_mode_gdt. Changing the .align ahead of compatibility_mode_far
>>> would eliminate the risk of padding appearing if the code further up
>>> changed.
>> Gaps will be formed of long nops because we're in .text, and they merge
>> with the previous data blob (see below).
>>
>>>> ffff82d040396136 <reloc_stack>:
>>>> ...
>>> Now this is particularly puzzling: Us setting %rsp to an unaligned
>>> address is clearly not ABI-conforming. Since you're fiddling with
>>> all of this already anyway, how about fixing this at the same time?
>>> Of course there would then appear padding ahead of the stack, unless
>>> the stack was moved up some.
>> Oh - I'd not even noticed that. Luckily there is no ABI which matters,
>> because it's the call/push/pop's in this file alone.
> And the entity transitioned to is forbidden to make use of our stack?
There's no expectation/guarantee of a good stack, no. Purgatory is a
very minimal environment before it sets something new up.
>> With an align 8, we get:
>>
>> ffff82d0403a7138 <compat_mode_idt>:
>> ffff82d0403a7138: 00 00 00 00 00 00 66
>> 90 ......f.
>>
>> ffff82d0403a7140 <reloc_stack>:
>> ...
>>
>> where the 66 90 in compat_mode_idt is the padding. Recall c/s 9fd181540c7e6
>>
>>>> --- a/xen/arch/x86/xen.lds.S
>>>> +++ b/xen/arch/x86/xen.lds.S
>>>> @@ -87,6 +87,7 @@ SECTIONS
>>>> *(.text.unlikely)
>>>> *(.fixup)
>>>> *(.text.kexec)
>>>> + kexec_reloc_end = .;
>>> Does this maybe want aligning on a 4- or even 8-byte boundary? If
>>> so, imo preferably not here, but by adding a trailing .align in the
>>> .S file.
>> There's no special need for it to be aligned, and it is anyway as the
>> stack is the last object in it.
> You mean it anyway would be, if the stack was aligned? Or am I to imply
> that you've amended the patch to add alignment there?
I have aligned reloc_stack stack because that's a no-brainer.
With that suitably aligned, kexec_reloc_end becomes aligned naturally
(because reloc_stack is the final object), and I don't think there's
much point putting anything explicit in the linker script.
It doesn't matter if subsequent things follow immediately, because this
trampoline is copied into the kexec region before being used. In
practice, the thing immediately following it is .init.text.
~Andrew
|