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

Re: [XEN v5 1/3] xen/arm: Introduce CONFIG_PARTIAL_EMULATION and "partial-emulation" cmd option


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Wed, 21 Feb 2024 11:33:22 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.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=yuYUIaR3PwI91XYPj4p6fO0tb69+oRj4kDID5JeBdm8=; b=K55rtfeVmWpY6wMuRvXHitKZdoALUG+rBEQpFMAIhmBe+ZIz0ELl3/i0KJiacSHlT97UYfCfTfgMGgPmMu+N96VGTiYoQpLN3AJNYSjgHr2Pl64ja42bLWEvoAL/heeZPBqG6a6aRtgOPTLOpsGzuk6ExMgk1BWPaFTB6Dq4KPrRCJReipWncM7+0lc0DXxGxd16Jq2jHxCdPK49BQ+NU4yIn9+ykcjaUncg9asSzVkKdrUK3Oje9XjXHuow0KoHbTlEp9XUjsdURMdnicQ3pfNLJ2INIClgaO3atCEUnX4e1EE18w5sxpzvy45f9IDSMmvwRE77+qd7BQCttZqLtA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZxRhdwy5Xq2euSxVx5Vt4ANXCB9HPfAAJl7ymv9dRR/mkZWuAcPgAKYVdQvw1EiBHMdZ94bwPJZC+fuXI/ynz30TEmmhLtQjLIUWqd4YgdpYB/RazFA9yWQwKTqhEXkboNz4+mSZP1/qQmJJCZE4c1ezKhPkJ7+FKg+fc0RBWQLsg++ZevOiYJCZ1O53KRJCbsS70MPmtuHX7TzsFgAVustaML/atXKQn9W03/5klHC+y3SRR9neDviRlDaIGcUolXnSp59mXhPa49Q4qJIawJRAXn6YqpkrxkYnmgX5osY5GOQqnJntXvLHqa8lhDRlJcjXYkSNUCQTYR4FyyWweA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: sstabellini@xxxxxxxxxx, stefano.stabellini@xxxxxxx, julien@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx, michal.orzel@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 21 Feb 2024 11:33:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

On 21/02/2024 07:09, Jan Beulich wrote:
On 20.02.2024 16:22, Ayan Kumar Halder wrote:
On 20/02/2024 12:33, Jan Beulich wrote:
On 20.02.2024 13:17, Ayan Kumar Halder wrote:
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -101,6 +101,18 @@ Extension to the GICv3 interrupt controller to support MSI.
Status: Experimental +### ARM/Partial Emulation
+
+Enable partial emulation of registers, otherwise considered unimplemented,
+that would normally trigger a fault injection.
+
+    Status: Supported, with caveats
+
+Bugs allowing the userspace to attack the guest OS will not be considered
+security vulnerabilities.
+
+Bugs that could compromise Xen will be considered security vulnerabilities.
... the odd statement regarding in-guest vulnerabilities that might be
introduced. I see only two ways of treating this as supported: Either
you simply refuse emulation when the access is from user space,
I am wondering how do we enforce that.

Let me try to understand this with the current implementation of partial
emulation for system registers.

1. DBGDTRTX_EL0 :- I understand that EL0 access to this register will
cause a trap to EL2. The reason being MDCR_EL2.TDA == 1.

In that case, if we refuse emulation then an undef exception is injected
to the guest (this is the behavior as of today even without this patch).

So, are you saying that the undef exception is to be injected to the
user space process. This may be possible for Arm64 guests
(inject_undef64_exception() needs to be changed).
No, injection is always to the guest, not to a specific entity within the
guest. That ought to be the same on bare hardware: An exception when
raised has an architecturally defined entry point for handling. That'll
typically be kernel code. The handler then figures out whether the source
of the exception was in user or kernel mode. For user mode code, the
kernel may or may not try to handle the exception and then continue the
user mode process. If it can't or doesn't want to handle it, it'll raise
(in UNIX terms) a signal to the process. That signal, in turn, may or may
not be fatal to the process. But such an exception from user mode should
never be fatal to the guest as a whole.
Thanks for explaining it so well.

However for Arm32 guests, this may not be possible as the mode changes
to PSR_MODE_UND.
I'm afraid my Arm foo isn't good enough to understand this. On the surface
it looks to violate above outlined principle.

Let me know if I understood you correctly.

or you
support that mode of emulation as much as that of kernel space accesses.
Do you mean we support partial emulation only for traps from EL1 mode ?
Possibly.

Now, I understand you. We will allow partial_emulation only from kernel mode.

So we need to do sth :-

if ( 'partial_emulation == true' && '!regs_mode_is_user(regs)' )

{

     /* partial_emulation logic */

}

I am ok with this.

And the updates message will be

### ARM/Partial Emulation

Enable partial emulation of registers, otherwise considered unimplemented,
that would normally trigger a fault injection.

    Status: Supported, with caveats

Partial emulation for traps from userspace is not allowed.

Bugs that could compromise Xen will be considered security vulnerabilities.

Also, want @Julien, @Michal to comment on this.

- Ayan


Jan



 


Rackspace

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