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

Re: [PATCH 02/15] xen/arm/gic: Enable interrupt assignment to running VM


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <xin.wang2@xxxxxxx>
  • Date: Wed, 8 May 2024 15:49:43 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=ilLXy8IYzm5SkskMIgeJHFmvXi8IaiFQks8Xz1TbKks=; b=gf9MN/AS3vAJox+j29tyjI/7rqmH0L8NyvduEJpSIYwF4P7dj39mHZatbTAYqbO8zM1XlxQUJ3Uy9ITm0ZCn12nVjDdKEHj9Mez1zUGH+tsD0Gw0F7ju/qIroZeUBJkt0NEZitRtyEIv3UHGoY+K4rLcLoDLYyLzmmZzxMSdsCOdpxlIXUfplR5dpDP/4cszJlbi1C6zK1w+Y1T8RLqJ5OWXlEK7wuFjtKMQxn3C0IpbQepol7ECAkm8mHD3nqH8BaOPJ2JtUA2czG9wiBAfsO6/w1PcW1efNF9XbizUkBtyn9FELjQ3/X2JOfx2LjPt53XeF73b1XJ7hb8kKe3FKg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YssFiGC9sbeMVOmlbZjwkqChFvt7qw7+0H4hDX9HSg/qHwUjpom09cGm0/jWPEl2Ce0MwWUjvij9avsZAG26AGMk5mD1U63eVFyzmx61ZrX9+f244ocxaW+mf0690ThMNzQPL8PWWkElbIKdwRYKKwy1pMCAg0TUlq+grI2Q3za4gSYJSx3oArPjsm2h0GZ1qkOKJb6meobjUGC4yWgv8dtzOX5v7DQzLXJlFdzcp4dmopRyZxm0nFt0NReUznt44b2qh9Kzc6wMWN7G5VIV0uFVIf2bzevkFoLV7OPBYVJNPaDh+00JEiu+g5/d2mD/vNTTwa1l6ySnlGAif6ok5g==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 08 May 2024 07:50:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

On 5/8/2024 5:54 AM, Julien Grall wrote:
Hi Henry,
What if the DT overlay is unloaded and then reloaded? Wouldn't the same interrupt be re-used? As a more generic case, this could also be a new bitstream for the FPGA.

But even if the interrupt is brand new every time for the DT overlay, you are effectively relaxing the check for every user (such as XEN_DOMCTL_bind_pt_irq). So the interrupt re-use case needs to be taken into account.

I agree. I think IIUC, with your explanation here and below, could we simplify the problem to how to properly handle the removal of the IRQ from a running guest, if we always properly remove and clean up the information when remove the IRQ from the guest? In this way, the IRQ can always be viewed as a brand new one when we add it back.

If we can make sure the virtual IRQ and physical IRQ is cleaned then yes.

Then the only corner case that we need to take care of would be...

Can you clarify whether you say the "only corner case" because you looked at the code? Or is it just because I mentioned only one?

Well, I indeed checked the code and to my best knowledge the corner case that you pointed out would be the only one I can think of.

Xen allows the guest to enable a vIRQ even if there is no pIRQ assigned. Thanksfully, it looks like the vgic_connect_hw_irq(), in both the current and new vGIC, will return an error if we are trying to route a pIRQ to an already enabled vIRQ.

But we need to investigate all the possible scenarios to make sure that any inconsistencies between the physical state and virtual state (including the LRs) will not result to bigger problem.

The one that comes to my mind is: The physical interrupt is de-assigned from the guest before it was EOIed. In this case, the interrupt will still be in the LR with the HW bit set. This would allow the guest to EOI the interrupt even if it is routed to someone else. It is unclear what would be the impact on the other guest.

...same as this case, i.e.
test_bit(_IRQ_INPROGRESS, &desc->status) || !test_bit(_IRQ_DISABLED, &desc->status)) when we try to remove the IRQ from a running domain.

We already call ->shutdown() which will disable the IRQ. So don't we only need to take care of _IRQ_INPROGRESS?

Yes you are correct.

we have 3 possible states which can be read from LR for this case : active, pending, pending and active. - I don't think we can do anything about the active state, so we should return -EBUSY and reject the whole operation of removing the IRQ from running guest, and user can always retry this operation.

This would mean a malicious/buggy guest would be able to prevent a device to be de-assigned. This is not a good idea in particular when the domain is dying.

That said, I think you can handle this case. The LR has a bit to indicate whether the pIRQ needs to be EOIed. You can clear it and this would prevent the guest to touch the pIRQ. There might be other clean-up to do in the vGIC datastructure.

I probably misunderstood this sentence, do you mean the EOI bit in the pINTID field? I think this bit is only available when the HW bit of LR is 0, but in our case the HW is supposed to be 1 (as indicated as your previous comment). Would you mind clarifying a bit more? Thanks!

Anyway, we don't have to handle removing an active IRQ when the domain is still running (although we do when the domain is destroying). But I think this would need to be solved before the feature is (security) supported.

- For the pending (and active) case,

Shouldn't the pending and active case handled the same way as the active case?

Sorry, yes you are correct.

Kind regards,
Henry



 


Rackspace

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