From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>,
Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 6/8] x86/IDT: Generate bsp_idt[] at build time
Date: Wed, 26 Feb 2025 15:14:34 +0000 [thread overview]
Message-ID: <e26cdb1a-9aa2-4ca2-94c2-c6c4afe9a46f@citrix.com> (raw)
In-Reply-To: <dff0e60a-e56a-4092-9641-6045a2712306@suse.com>
On 26/02/2025 2:14 pm, Jan Beulich wrote:
> On 26.02.2025 14:37, Andrew Cooper wrote:
>> On 26/02/2025 12:39 pm, Jan Beulich wrote:
>>> On 24.02.2025 17:05, Andrew Cooper wrote:
>>>> --- /dev/null
>>>> +++ b/xen/arch/x86/include/asm/gen-idt.h
>>>> @@ -0,0 +1,121 @@
>>>> +/*
>>>> + * Generator for IDT entries.
>>>> + *
>>>> + * Caller to provide GEN(vector, symbol, dpl, autogen) macro
>>>> + *
>>>> + * Symbols are 'entry_0xYY' if there is no better name available. Regular
>>>> + * handlers set autogen=1, while manual (autogen=0) require the symbol to be
>>>> + * implemented somewhere else.
>>>> + */
>>> Doesn't this need something for Eclair to spot the deliberate absence of a
>>> header guard?
>> Eclair doesn't complain, although I'm not entirely sure why.
>>
>>>> +#define DPL0 0
>>>> +#define DPL1 1
>>>> +#define DPL3 3
>>>> +
>>>> +#define manual 0
>>>> +#define autogen 1
>>>> +
>>>> +#define GEN16(i) \
>>>> + GEN(0x ## i ## 0, entry_0x ## i ## 0, DPL0, autogen) \
>>>> + GEN(0x ## i ## 1, entry_0x ## i ## 1, DPL0, autogen) \
>>>> + GEN(0x ## i ## 2, entry_0x ## i ## 2, DPL0, autogen) \
>>>> + GEN(0x ## i ## 3, entry_0x ## i ## 3, DPL0, autogen) \
>>>> + GEN(0x ## i ## 4, entry_0x ## i ## 4, DPL0, autogen) \
>>>> + GEN(0x ## i ## 5, entry_0x ## i ## 5, DPL0, autogen) \
>>>> + GEN(0x ## i ## 6, entry_0x ## i ## 6, DPL0, autogen) \
>>>> + GEN(0x ## i ## 7, entry_0x ## i ## 7, DPL0, autogen) \
>>>> + GEN(0x ## i ## 8, entry_0x ## i ## 8, DPL0, autogen) \
>>>> + GEN(0x ## i ## 9, entry_0x ## i ## 9, DPL0, autogen) \
>>>> + GEN(0x ## i ## a, entry_0x ## i ## a, DPL0, autogen) \
>>>> + GEN(0x ## i ## b, entry_0x ## i ## b, DPL0, autogen) \
>>>> + GEN(0x ## i ## c, entry_0x ## i ## c, DPL0, autogen) \
>>>> + GEN(0x ## i ## d, entry_0x ## i ## d, DPL0, autogen) \
>>>> + GEN(0x ## i ## e, entry_0x ## i ## e, DPL0, autogen) \
>>>> + GEN(0x ## i ## f, entry_0x ## i ## f, DPL0, autogen)
>>>> +
>>>> +
>>>> +GEN(0x00, entry_DE, DPL0, manual)
>>>> +GEN(0x01, entry_DB, DPL0, manual)
>>>> +GEN(0x02, entry_NMI, DPL0, manual)
>>>> +GEN(0x03, entry_BP, DPL3, manual)
>>>> +GEN(0x04, entry_OF, DPL3, manual)
>>> Would this better be
>>>
>>> #ifdef CONFIG_PV32
>>> GEN(0x04, entry_OF, DPL3, manual)
>>> #else
>>> GEN(0x04, entry_0x04, DPL0, autogen)
>>> #endif
>>>
>>> ? (Not necessarily in this patch, but in principle.)
>> No. INTO can still be used in compatibility mode segment.
> Oh, of course.
>
>> Furthermore, for any exception we know about, we want a manual one to
>> avoid the error-code realignment logic where possible.
> Why would that not apply to Co-processor Segment Overrun then?
It kinda does apply.
We've never ever had CSO handler (hence why it was autogen'd the first
time I tried making this more robust), and you didn't like my patch to
autogen the exception entries.
The CSO handler (and SPV) are the only two we can be pretty confident
will never trigger on today's hardware, yet you also didn't like my
suggestion of having them Not Present.
>>>> --- /dev/null
>>>> +++ b/xen/arch/x86/include/asm/gen-idt.lds.h
>>>> @@ -0,0 +1,27 @@
>>>> +/*
>>>> + * Linker file fragment to help format the IDT correctly
>>>> + *
>>>> + * The IDT, having grown compatibly since the 16 bit days, has the entrypoint
>>>> + * address field split into 3. x86 ELF lacks the @lo/@hi/etc relocation forms
>>>> + * commonly found in other architectures for accessing a part of a resolved
>>>> + * symbol address.
>>>> + *
>>>> + * However, the linker can perform the necessary calculations and provide them
>>>> + * under new symbol names. We use this to generate the low and next 16 bits
>>>> + * of the address for each handler.
>>>> + *
>>>> + * The upper 32 bits are always a constant as Xen's .text/data/rodata sits in
>>>> + * a single aligned 1G range, so do not need calculating in this manner.
>>>> + */
>>>> +#ifndef X86_IDT_GEN_LDS_H
>>>> +#define X86_IDT_GEN_LDS_H
>>>> +
>>>> +#define GEN(vec, sym, dpl, auto) \
>>>> + PROVIDE_HIDDEN(IDT_ ## sym ## _ADDR1 = ABSOLUTE(((sym) & 0xffff))); \
>>>> + PROVIDE_HIDDEN(IDT_ ## sym ## _ADDR2 = ABSOLUTE(((sym >> 16) & 0xffff)));
>>> Not sure if Eclair gets to see this at all, but maybe better parenthesize
>>> sym also in the latter instance?
>> Oh, yes.
>>
>>> As to the final semicolon - ideally this would be on the use sites of GEN(),
>>> for things to look more C-ish. Yet I won't insist, as gen-idt.h ends up
>>> looking sufficiently uniform for this to not be a major concern.
>> I'm afraid it's necessary (and too in entry stubs).
>>
>> It's the GEN16() macro, which expands 16x GEN() on the same line.
> Right, as said - the semicolons would need putting after every GEN() invocation,
> including in GEN16() (with the final one likely excluded, for the semicolon then
> to appear on its use site).
Ah, I see what you mean. I'll see if I can make it work.
~Andrew
next prev parent reply other threads:[~2025-02-26 15:14 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 16:05 [PATCH 0/8] x86/IDT: Generate the IDT at build time Andrew Cooper
2025-02-24 16:05 ` [PATCH 1/8] x86: Sort includes in various files Andrew Cooper
2025-02-24 16:11 ` Jan Beulich
2025-02-24 16:05 ` [PATCH 2/8] x86/IDT: Collect IDT related content idt.h Andrew Cooper
2025-02-25 8:27 ` Jan Beulich
2025-02-26 17:15 ` Andrew Cooper
2025-02-27 7:49 ` Jan Beulich
2025-02-24 16:05 ` [PATCH 3/8] x86/IDT: Rename X86_NR_VECTORS to X86_IDT_VECTORS Andrew Cooper
2025-02-25 8:31 ` Jan Beulich
2025-02-26 17:27 ` Andrew Cooper
2025-02-27 7:57 ` Jan Beulich
2025-02-24 16:05 ` [PATCH 4/8] x86/IDT: Rename idt_table[] to bsp_idt[] Andrew Cooper
2025-02-25 9:00 ` Jan Beulich
2025-02-25 12:54 ` Andrew Cooper
2025-02-25 14:33 ` Jan Beulich
2025-02-25 16:20 ` Andrew Cooper
2025-02-25 16:29 ` Jan Beulich
2025-02-24 16:05 ` [PATCH 5/8] x86/IDT: Make idt_tables[] be per_cpu(idt) Andrew Cooper
2025-02-25 9:07 ` Jan Beulich
2025-02-25 15:40 ` Andrew Cooper
2025-02-25 16:33 ` Jan Beulich
2025-03-04 14:40 ` Andrew Cooper
2025-02-24 16:05 ` [PATCH 6/8] x86/IDT: Generate bsp_idt[] at build time Andrew Cooper
2025-02-26 12:39 ` Jan Beulich
2025-02-26 13:37 ` Andrew Cooper
2025-02-26 14:14 ` Jan Beulich
2025-02-26 15:14 ` Andrew Cooper [this message]
2025-02-24 16:05 ` [PATCH 7/8] x86/IDT: Don't rewrite bsp_idt[] at boot time Andrew Cooper
2025-02-26 12:48 ` Jan Beulich
2025-02-26 12:53 ` Andrew Cooper
2025-02-26 13:18 ` Jan Beulich
2025-02-26 13:23 ` Andrew Cooper
2025-02-24 16:05 ` [PATCH 8/8] x86/traps: Convert pv_trap_init() to being an initcall Andrew Cooper
2025-02-26 12:53 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e26cdb1a-9aa2-4ca2-94c2-c6c4afe9a46f@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.