From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>,
Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 2/8] x86/IDT: Collect IDT related content idt.h
Date: Thu, 27 Feb 2025 08:49:06 +0100 [thread overview]
Message-ID: <7acb14ac-07ed-4f7f-8f8a-c38e04ddc06e@suse.com> (raw)
In-Reply-To: <9a16c457-99a4-4adf-95c9-3f743f05963f@citrix.com>
On 26.02.2025 18:15, Andrew Cooper wrote:
> On 25/02/2025 8:27 am, Jan Beulich wrote:
>> On 24.02.2025 17:05, Andrew Cooper wrote:
>>> --- /dev/null
>>> +++ b/xen/arch/x86/include/asm/idt.h
>>> @@ -0,0 +1,125 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-only */
>>> +#ifndef X86_ASM_IDT_H
>>> +#define X86_ASM_IDT_H
>>> +
>>> +#include <xen/bug.h>
>>> +#include <xen/types.h>
>>> +
>>> +#include <asm/x86-defns.h>
>>> +
>>> +#define IST_NONE 0
>>> +#define IST_MCE 1
>>> +#define IST_NMI 2
>>> +#define IST_DB 3
>>> +#define IST_DF 4
>>> +#define IST_MAX 4
>>> +
>>> +typedef union {
>>> + struct {
>>> + uint64_t a, b;
>>> + };
>>> + struct {
>>> + uint16_t addr0;
>>> + uint16_t cs;
>>> + uint8_t ist; /* :3, 5 bits rsvd, but this yields far better code. */
>>> + uint8_t type:4, s:1, dpl:2, p:1;
>>> + uint16_t addr1;
>>> + uint32_t addr2;
>>> + /* 32 bits rsvd. */
>>> + };
>>> +} idt_entry_t;
>>> +
>>> +#define IDT_ENTRIES 256
>>> +extern idt_entry_t idt_table[];
>>> +extern idt_entry_t *idt_tables[];
>>> +
>>> +/*
>>> + * Set the Interrupt Stack Table used by a particular IDT entry. Typically
>>> + * used on a live IDT, so volatile to disuade clever optimisations.
>>> + */
>>> +static inline void set_ist(volatile idt_entry_t *idt, unsigned int ist)
>>> +{
>>> + /* IST is a 3 bit field, 32 bits into the IDT entry. */
>>> + ASSERT(ist <= IST_MAX);
>>> +
>>> + idt->ist = ist;
>>> +}
>>> +
>>> +static inline void enable_each_ist(idt_entry_t *idt)
>>> +{
>>> + set_ist(&idt[X86_EXC_DF], IST_DF);
>>> + set_ist(&idt[X86_EXC_NMI], IST_NMI);
>>> + set_ist(&idt[X86_EXC_MC], IST_MCE);
>>> + set_ist(&idt[X86_EXC_DB], IST_DB);
>>> +}
>>> +
>>> +static inline void disable_each_ist(idt_entry_t *idt)
>>> +{
>>> + set_ist(&idt[X86_EXC_DF], IST_NONE);
>>> + set_ist(&idt[X86_EXC_NMI], IST_NONE);
>>> + set_ist(&idt[X86_EXC_MC], IST_NONE);
>>> + set_ist(&idt[X86_EXC_DB], IST_NONE);
>>> +}
>>> +
>>> +/*
>>> + * Write the lower 64 bits of an IDT Entry. This relies on the upper 32
>>> + * bits of the address not changing, which is a safe assumption as all
>>> + * functions we are likely to load will live inside the 1GB
>>> + * code/data/bss address range.
>>> + */
>>> +static inline void _write_gate_lower(volatile idt_entry_t *gate,
>>> + const idt_entry_t *new)
>>> +{
>>> + ASSERT(gate->b == new->b);
>>> + gate->a = new->a;
>>> +}
>> Would this better move down a few lines, immediately ahead of its two
>> use sites?
>>
>>> +#define _set_gate(gate_addr,type,dpl,addr) \
>> Moving this is questionable, as gates aren't limited to the IDT (in
>> principle; yes, we don't use call gates ourselves). However, as you
>> move it, my minimal request would be to add the missing blanks here.
>
> _set_gate() doesn't survive to the end of the series, which also fixes
> the position of _write_gate_lower().
Hmm, okay:
Acked-by: Jan Beulich <jbeulich@suse.com>
Jan
next prev parent reply other threads:[~2025-02-27 7:49 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 [this message]
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
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=7acb14ac-07ed-4f7f-8f8a-c38e04ddc06e@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.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.