[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 16:49:35 +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 15:49:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11.01.2024 16:24, Andrew Cooper wrote:
> On 11/01/2024 12:11 pm, Jan Beulich wrote:
>>>> 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?
> 
> I presume you mean crash?

Oops, yes, I do.

> I'm not advocating for leaving something explicitly unsafe, but I'm also
> looking to see if we can avoid having keypress_regs to begin with.  i.e.
> I think we've already got unnecessary complexity, and it would be good
> to reduce it.
>[...]
>>> 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.
> 
> The serial IRQ producing the 'd' keypress will push a irq frame, which
> is what will be returned by get_irq_regs().

Hmm, yes. I wonder what I was thinking ...

> It does occur to me that we're trying to accommodate for two behaviours
> here.
> 
> For a real keypress, we want to dump from the the point the interrupt
> hit because that's the interesting bit of stack to see.  For a SYSCTL,
> there's nothing, and we're using BUGFRAME_run_fn to generate one.

There's three forms of handle_keypress() invocations really, and hence
why (after having dropped the regs parameter already) I re-instated it.

As an aside - no, sysctl handling does not generate an exception frame.
Is uses guest_cpu_user_regs() (and imo validly so).

> So actually we just simply want "regs = get_irq_regs();" here and retain
> prior NULL check, don't we?

As per above, after I had it that way first, I backed off to accommodate
all present use forms of handle_keypress(). But dealing with that (in
whichever way we may end up deeming workable) can be separate anyway,
afaict.

Jan



 


Rackspace

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