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

Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 11 Jan 2024 13:11:42 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 11 Jan 2024 12:11:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11.01.2024 12:49, Andrew Cooper wrote:
> On 11/01/2024 7:31 am, Jan Beulich wrote:
>> There are exactly two handlers which care about the registers.
> 
> Which two?  dump regs and trap to debugger?
> 
> [Edit, oh yes, this is clear in the patch, but IMO it would be helpful
> to state them here.]

Sure, added mention of 'd' and '%'.

>> Have
>> handle_keypress() make the pointer available via a per-CPU variable,
>> thus eliminating the need to pass it to all IRQ key handlers, making
>> sure that a console-invoked key's handling can still nest inside a
>> sysctl-invoked one's.
> 
> I know this is the current behaviour, and I'm not suggesting altering it
> in this patch, but the sysctl was added so you had a way of using debug
> keys without necessarily having a working serial connection.
> 
> It was never expected or intended for both mechanisms to work
> concurrently, and I don't think we need to take any care to make/keep it
> working.

Well, all it takes is the saving and restoring of keypress_regs in
handle_keypress(). You you really think it would be better to risk
a cash, but not doing that tiny bit of extra work?

>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> with a few trivial
> tweaks, but see below.

Thanks, and yes, I've inserted the two blank lines.

>> ---
>> Subsequently we may want to eliminate the fn/irq_fn union as well,
>> along with dropping the now redundant irq_keyhandler_fn_t.
> 
> Yes - this simplification was one I was hoping to be able to make in due
> course.  I suspect the split is only because some functionality wanted
> regs and others not.

That's my recollection, yes.

> Trap to debugger is an x86-ism for gdbstub only.  I'm tempted to drop
> all the gdbstub code.  I've never encountered it working in 13y, and the
> number of build fixes I've done personally, I don't believe the code can
> plausibly be in a non-bitrotten state.
> 
> Nevertheless, an explicit trap-to-debugger which isn't a manually
> inserted debugger_trap_{immediate,fatal}() is a weird construct in the
> first place, not least because an attached debugger can do this on its
> own anyway.

Not sure here, and I'd hope purging of that (if so wanted) can be dealt
with separately. I have a vague recollection of such "on its own" wasn't
very reliable, when trying to use such elsewhere (in the distant past,
before I started working on Xen). That's not to say that I have proof
that our debug-key is any more reliable.

> The more I think about this, the more I think we should just remove 'D',
> even if we don't go for dropping gdbstub.  It's the only place where
> gdbstub really escapes out of x86 into common code.  (I see there's a
> new one in bug.h but that is abstracted with a macro.)
> 
> Also, `xl debug-keys D` was clearly something that just got swept up
> with "make all debug keys usable via sysctl", not because it was a
> plausibly useful construct.

Did you really mean D (EPT table dump), not %? If the latter, then yes,
that may better be filtered out of what can be done via sysctl.

> This just leaves dump regs, which I think can safely use get_irq_regs()
> || guest_cpu_user_regs().  All it wants is something to dump_execstate()
> to, which just wants to be the start of the path which led here.

I don't think so - consider the case of 'd' hitting while handling an
interrupt (and, say, stuck there in an infinite loop with IRQs enabled).
We'd then wrongly dump the context of what the earlier IRQ interrupted.

Jan



 


Rackspace

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