All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Antonios Motakis <antonios.motakis@huawei.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	<kvmarm@lists.cs.columbia.edu>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <kvm@vger.kernel.org>,
	"Claudio Fontana" <claudio.fontana@huawei.com>,
	<jani.kokkonen@huawei.com>
Subject: Re: [PATCH 00/13] arm64: Virtualization Host Extension support
Date: Fri, 28 Aug 2015 08:04:25 +0100	[thread overview]
Message-ID: <20150828080425.4fb41861@arm.com> (raw)
In-Reply-To: <55DDA024.8040303@huawei.com>

On Wed, 26 Aug 2015 13:16:52 +0200
Antonios Motakis <antonios.motakis@huawei.com> wrote:
> On 26-Aug-15 11:59, Marc Zyngier wrote:

[...]

> > Unfortunately, there is more to downgrading to EL1 than just interrupts.
> > You need to migrate the whole VM context from EL2 to EL1 in an atomic
> > fashion, clear the HCR_EL2.E2H and HCR_EL2.TGE bits while running at EL2
> > (which is a bit like pulling the rug from under your own feet so you
> > need to transition via a low mapping or an idmap), reinstall the EL2
> > stub and do an exception return into EL1.
> 
> When enabling Jailhouse, we already do most of that. We already use
> identity mapping, since we need to switch on the MMU for EL2, switch
> the exception level, etc. Jailhouse entry looks a lot like
> initializing a new kernel; we just save the state of what was running
> before it and restore it as the "root cell".
> 
> So I think we could handle the cpu context switch, with changes only
> in the Jailhouse entry code. But then of course, Linux would be
> expecting to be in EL2, while it is running in EL1, so we would have
> to emulate the differences in behavior. But...

There would be (almost) no difference in behaviour - VHE is designed
for the kernel to be unchanged, and the only difference is the timer
interrupt as you noticed.

What is really tricky is to perform the downgrade, because you're
completely changing the way the code is executed *while running it*.
This is not just about changing the memory map, but also changing the
effect of most system registers.

> 
> > 
> > And that's only for the CPU. Downgrading to EL1 has other fun
> > consequences at the system level (SMMUs listening to TLB traffic
> > would need to be reconfigured on the flight - it's a joke, don't
> > even think of it).
> 
> ...but then there's that.
> 
> Hm... even if the kernel is running in EL2, it will still be
> configuring stage 1 on the SMMU, no? I wonder if this could still be
> handled somehow... The root cell would be restored with identity
> mapping, too... Just thinking out loud :)

Stage-1 and EL2 are two vastly unrelated concept. The main issue is
that it is likely that your SMMU knows about VHE as well (it listens to
EL2-VHE DVM messages), and need to be reconfigured as well. Good luck
with that.

[...]

> > As far as I can see, the only practical solution to this is to have
> > a VHE config option, and Jailhouse that can be set to conflict it
> > (depends on !VHE).
> 
> Having a toggle to turn VHE off at build time would definitely be the
> easy way out. Then we can just tell the user that we only support
> kernels built without it (the Jailhouse driver is out of tree atm).
> 
> I don't have access to a VHE model though. Are you considering to add
> a config option for VHE in the next version of your patches?

Yes, that's the plan.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Antonios Motakis <antonios.motakis@huawei.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	Claudio Fontana <claudio.fontana@huawei.com>,
	jani.kokkonen@huawei.com
Subject: Re: [PATCH 00/13] arm64: Virtualization Host Extension support
Date: Fri, 28 Aug 2015 08:04:25 +0100	[thread overview]
Message-ID: <20150828080425.4fb41861@arm.com> (raw)
In-Reply-To: <55DDA024.8040303@huawei.com>

On Wed, 26 Aug 2015 13:16:52 +0200
Antonios Motakis <antonios.motakis@huawei.com> wrote:
> On 26-Aug-15 11:59, Marc Zyngier wrote:

[...]

> > Unfortunately, there is more to downgrading to EL1 than just interrupts.
> > You need to migrate the whole VM context from EL2 to EL1 in an atomic
> > fashion, clear the HCR_EL2.E2H and HCR_EL2.TGE bits while running at EL2
> > (which is a bit like pulling the rug from under your own feet so you
> > need to transition via a low mapping or an idmap), reinstall the EL2
> > stub and do an exception return into EL1.
> 
> When enabling Jailhouse, we already do most of that. We already use
> identity mapping, since we need to switch on the MMU for EL2, switch
> the exception level, etc. Jailhouse entry looks a lot like
> initializing a new kernel; we just save the state of what was running
> before it and restore it as the "root cell".
> 
> So I think we could handle the cpu context switch, with changes only
> in the Jailhouse entry code. But then of course, Linux would be
> expecting to be in EL2, while it is running in EL1, so we would have
> to emulate the differences in behavior. But...

There would be (almost) no difference in behaviour - VHE is designed
for the kernel to be unchanged, and the only difference is the timer
interrupt as you noticed.

What is really tricky is to perform the downgrade, because you're
completely changing the way the code is executed *while running it*.
This is not just about changing the memory map, but also changing the
effect of most system registers.

> 
> > 
> > And that's only for the CPU. Downgrading to EL1 has other fun
> > consequences at the system level (SMMUs listening to TLB traffic
> > would need to be reconfigured on the flight - it's a joke, don't
> > even think of it).
> 
> ...but then there's that.
> 
> Hm... even if the kernel is running in EL2, it will still be
> configuring stage 1 on the SMMU, no? I wonder if this could still be
> handled somehow... The root cell would be restored with identity
> mapping, too... Just thinking out loud :)

Stage-1 and EL2 are two vastly unrelated concept. The main issue is
that it is likely that your SMMU knows about VHE as well (it listens to
EL2-VHE DVM messages), and need to be reconfigured as well. Good luck
with that.

[...]

> > As far as I can see, the only practical solution to this is to have
> > a VHE config option, and Jailhouse that can be set to conflict it
> > (depends on !VHE).
> 
> Having a toggle to turn VHE off at build time would definitely be the
> easy way out. Then we can just tell the user that we only support
> kernels built without it (the Jailhouse driver is out of tree atm).
> 
> I don't have access to a VHE model though. Are you considering to add
> a config option for VHE in the next version of your patches?

Yes, that's the plan.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

WARNING: multiple messages have this Message-ID (diff)
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 00/13] arm64: Virtualization Host Extension support
Date: Fri, 28 Aug 2015 08:04:25 +0100	[thread overview]
Message-ID: <20150828080425.4fb41861@arm.com> (raw)
In-Reply-To: <55DDA024.8040303@huawei.com>

On Wed, 26 Aug 2015 13:16:52 +0200
Antonios Motakis <antonios.motakis@huawei.com> wrote:
> On 26-Aug-15 11:59, Marc Zyngier wrote:

[...]

> > Unfortunately, there is more to downgrading to EL1 than just interrupts.
> > You need to migrate the whole VM context from EL2 to EL1 in an atomic
> > fashion, clear the HCR_EL2.E2H and HCR_EL2.TGE bits while running at EL2
> > (which is a bit like pulling the rug from under your own feet so you
> > need to transition via a low mapping or an idmap), reinstall the EL2
> > stub and do an exception return into EL1.
> 
> When enabling Jailhouse, we already do most of that. We already use
> identity mapping, since we need to switch on the MMU for EL2, switch
> the exception level, etc. Jailhouse entry looks a lot like
> initializing a new kernel; we just save the state of what was running
> before it and restore it as the "root cell".
> 
> So I think we could handle the cpu context switch, with changes only
> in the Jailhouse entry code. But then of course, Linux would be
> expecting to be in EL2, while it is running in EL1, so we would have
> to emulate the differences in behavior. But...

There would be (almost) no difference in behaviour - VHE is designed
for the kernel to be unchanged, and the only difference is the timer
interrupt as you noticed.

What is really tricky is to perform the downgrade, because you're
completely changing the way the code is executed *while running it*.
This is not just about changing the memory map, but also changing the
effect of most system registers.

> 
> > 
> > And that's only for the CPU. Downgrading to EL1 has other fun
> > consequences at the system level (SMMUs listening to TLB traffic
> > would need to be reconfigured on the flight - it's a joke, don't
> > even think of it).
> 
> ...but then there's that.
> 
> Hm... even if the kernel is running in EL2, it will still be
> configuring stage 1 on the SMMU, no? I wonder if this could still be
> handled somehow... The root cell would be restored with identity
> mapping, too... Just thinking out loud :)

Stage-1 and EL2 are two vastly unrelated concept. The main issue is
that it is likely that your SMMU knows about VHE as well (it listens to
EL2-VHE DVM messages), and need to be reconfigured as well. Good luck
with that.

[...]

> > As far as I can see, the only practical solution to this is to have
> > a VHE config option, and Jailhouse that can be set to conflict it
> > (depends on !VHE).
> 
> Having a toggle to turn VHE off at build time would definitely be the
> easy way out. Then we can just tell the user that we only support
> kernels built without it (the Jailhouse driver is out of tree atm).
> 
> I don't have access to a VHE model though. Are you considering to add
> a config option for VHE in the next version of your patches?

Yes, that's the plan.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

  reply	other threads:[~2015-08-28  7:04 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 16:19 [PATCH 00/13] arm64: Virtualization Host Extension support Marc Zyngier
2015-07-08 16:19 ` Marc Zyngier
2015-07-08 16:19 ` Marc Zyngier
2015-07-08 16:19 ` [PATCH 01/13] arm/arm64: Add new is_kernel_in_hyp_mode predicate Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-09  9:42   ` Mark Rutland
2015-07-09  9:42     ` Mark Rutland
2015-07-09  9:42     ` Mark Rutland
2015-07-09 10:05     ` Marc Zyngier
2015-07-09 10:05       ` Marc Zyngier
2015-07-09 10:05       ` Marc Zyngier
2015-07-09 10:12       ` Mark Rutland
2015-07-09 10:12         ` Mark Rutland
2015-07-09 10:12         ` Mark Rutland
2015-07-16 18:08   ` Will Deacon
2015-07-16 18:08     ` Will Deacon
2015-07-16 18:08     ` Will Deacon
2015-07-08 16:19 ` [PATCH 02/13] arm64: Allow the arch timer to use the HYP timer Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19 ` [PATCH 03/13] arm64: Add ARM64_HAS_VIRT_HOST_EXTN feature Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-09  9:48   ` Mark Rutland
2015-07-09  9:48     ` Mark Rutland
2015-07-09  9:48     ` Mark Rutland
2015-07-09  9:59     ` Marc Zyngier
2015-07-09  9:59       ` Marc Zyngier
2015-07-09  9:59       ` Marc Zyngier
2015-07-16 18:04   ` Will Deacon
2015-07-16 18:04     ` Will Deacon
2015-07-16 18:04     ` Will Deacon
2015-07-08 16:19 ` [PATCH 04/13] arm64: KVM: skip HYP setup when already running in HYP Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19 ` [PATCH 05/13] arm64: KVM: VHE: macroize VTCR_EL2 setup Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19 ` [PATCH 06/13] arm64: KVM: VHE: Patch out kern_hyp_va Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19 ` [PATCH 07/13] arm64: KVM: VHE: Patch out use of HVC Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 17:14   ` Paolo Bonzini
2015-07-08 17:14     ` Paolo Bonzini
2015-07-08 17:14     ` Paolo Bonzini
2015-07-08 17:54     ` Marc Zyngier
2015-07-08 17:54       ` Marc Zyngier
2015-07-08 17:54       ` Marc Zyngier
2015-07-10 11:02       ` Paolo Bonzini
2015-07-10 11:02         ` Paolo Bonzini
2015-07-10 11:02         ` Paolo Bonzini
2015-08-05 17:57   ` Catalin Marinas
2015-08-05 17:57     ` Catalin Marinas
2015-07-08 16:19 ` [PATCH 08/13] arm64: KVM: VHE: Preserve VHE config in world switch Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19 ` [PATCH 09/13] arm64: KVM: VHE: Add alternatives for VHE-enabled world-switch Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-09  1:29   ` Mario Smarduch
2015-07-09  1:29     ` Mario Smarduch
2015-07-09  8:06     ` Marc Zyngier
2015-07-09  8:06       ` Marc Zyngier
2015-07-09  8:06       ` Marc Zyngier
2015-07-09 20:58       ` Mario Smarduch
2015-07-09 20:58         ` Mario Smarduch
2015-07-09 20:58         ` Mario Smarduch
2015-08-31 18:46   ` Christoffer Dall
2015-08-31 18:46     ` Christoffer Dall
2015-07-08 16:19 ` [PATCH 10/13] arm64: Add support for running Linux in EL2 mode Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-16 17:48   ` Will Deacon
2015-07-16 17:48     ` Will Deacon
2015-07-16 17:48     ` Will Deacon
2015-07-08 16:19 ` [PATCH 11/13] arm64: Panic when VHE and non VHE CPUs coexist Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-16 18:03   ` Will Deacon
2015-07-16 18:03     ` Will Deacon
2015-07-16 18:03     ` Will Deacon
2015-08-06 14:08   ` Catalin Marinas
2015-08-06 14:08     ` Catalin Marinas
2015-08-06 14:08     ` Catalin Marinas
2015-07-08 16:19 ` [PATCH 12/13] arm64: KVM: Split sysreg save/restore Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-08-31 18:49   ` Christoffer Dall
2015-08-31 18:49     ` Christoffer Dall
2015-07-08 16:19 ` [PATCH 13/13] arm64: KVM: VHE: Early interrupt handling Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-07-08 16:19   ` Marc Zyngier
2015-08-31 18:52   ` Christoffer Dall
2015-08-31 18:52     ` Christoffer Dall
2015-08-06 17:43 ` [PATCH 00/13] arm64: Virtualization Host Extension support Catalin Marinas
2015-08-06 17:43   ` Catalin Marinas
2015-08-26  9:12 ` Antonios Motakis
2015-08-26  9:12   ` Antonios Motakis
2015-08-26  9:12   ` Antonios Motakis
2015-08-26  9:21   ` Jan Kiszka
2015-08-26  9:21     ` Jan Kiszka
2015-08-26  9:28     ` Antonios Motakis
2015-08-26  9:28       ` Antonios Motakis
2015-08-26  9:28       ` Antonios Motakis
2015-08-26  9:54       ` Jan Kiszka
2015-08-26  9:54         ` Jan Kiszka
2015-08-26  9:54         ` Jan Kiszka
2015-08-26  9:59     ` Marc Zyngier
2015-08-26  9:59       ` Marc Zyngier
2015-08-26  9:59       ` Marc Zyngier
2015-08-26 11:16       ` Antonios Motakis
2015-08-26 11:16         ` Antonios Motakis
2015-08-26 11:16         ` Antonios Motakis
2015-08-28  7:04         ` Marc Zyngier [this message]
2015-08-28  7:04           ` Marc Zyngier
2015-08-28  7:04           ` Marc Zyngier

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=20150828080425.4fb41861@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=antonios.motakis@huawei.com \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=claudio.fontana@huawei.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jani.kokkonen@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /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.