From: Marc Zyngier <maz@kernel.org>
To: Jianyong Wu <Jianyong.Wu@arm.com>
Cc: Justin He <Justin.He@arm.com>,
Steve Capper <Steve.Capper@arm.com>,
Suzuki Poulose <Suzuki.Poulose@arm.com>,
James Morse <James.Morse@arm.com>, nd <nd@arm.com>,
will@kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64/kvm: correct the error report in kvm_handle_guest_abort
Date: Thu, 28 Jan 2021 09:07:11 +0000 [thread overview]
Message-ID: <f11a46325548ad5b93e24f4cfdb22d65@kernel.org> (raw)
In-Reply-To: <VE1PR08MB47665F987B86F85454434377F4BA9@VE1PR08MB4766.eurprd08.prod.outlook.com>
On 2021-01-28 03:01, Jianyong Wu wrote:
> Hi Marc,
>
>>
>> From 8f2a919d6f13d36445974794c76821fbb6b40f88 Mon Sep 17 00:00:00
>> 2001
>> From: Marc Zyngier <maz@kernel.org>
>> Date: Sat, 16 Jan 2021 10:53:21 +0000
>> Subject: [PATCH] CMO on RO memslot
>>
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> ---
>> arch/arm64/kvm/mmu.c | 51 +++++++++++++++++++++++++++++++++----
>> -------
>> 1 file changed, 39 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index
>> 7d2257cc5438..3c176b5b0a28 100644
>> --- a/arch/arm64/kvm/mmu.c
>> +++ b/arch/arm64/kvm/mmu.c
>> @@ -760,7 +760,15 @@ static int user_mem_abort(struct kvm_vcpu *vcpu,
>> phys_addr_t fault_ipa,
>> struct kvm_pgtable *pgt;
>>
>> fault_granule = 1UL <<
>> ARM64_HW_PGTABLE_LEVEL_SHIFT(fault_level);
>> - write_fault = kvm_is_write_fault(vcpu);
>> + /*
>> + * Treat translation faults on CMOs as read faults. Should
>> + * this further generate a permission fault, it will be caught
>> + * in kvm_handle_guest_abort(), with prejudice...
>> + */
>> + if (fault_status == FSC_FAULT && kvm_vcpu_dabt_is_cm(vcpu))
>> + write_fault = false;
>> + else
>> + write_fault = kvm_is_write_fault(vcpu);
>> exec_fault = kvm_vcpu_trap_is_exec_fault(vcpu);
>> VM_BUG_ON(write_fault && exec_fault);
>>
>> @@ -1013,19 +1021,37 @@ int kvm_handle_guest_abort(struct kvm_vcpu
>> *vcpu)
>> }
>>
>> /*
>> - * Check for a cache maintenance operation. Since we
>> - * ended-up here, we know it is outside of any memory
>> - * slot. But we can't find out if that is for a device,
>> - * or if the guest is just being stupid. The only thing
>> - * we know for sure is that this range cannot be cached.
>> + * Check for a cache maintenance operation. Two cases:
>> + *
>> + * - It is outside of any memory slot. But we can't find out
>> + * if that is for a device, or if the guest is just being
>> + * stupid. The only thing we know for sure is that this
>> + * range cannot be cached. So let's assume that the guest
>> + * is just being cautious, and skip the instruction.
>> + *
>> + * - Otherwise, check whether this is a permission fault.
>> + * If so, that's a DC IVAC on a R/O memslot, which is a
>> + * pretty bad idea, and we tell the guest so.
>> *
>> - * So let's assume that the guest is just being
>> - * cautious, and skip the instruction.
>> + * - If this wasn't a permission fault, pass it along for
>> + * further handling (including faulting the page in
>> if it
>> + * was a translation fault).
>> */
>> - if (kvm_is_error_hva(hva) && kvm_vcpu_dabt_is_cm(vcpu))
>> {
>> - kvm_incr_pc(vcpu);
>> - ret = 1;
>> - goto out_unlock;
>> + if (kvm_vcpu_dabt_is_cm(vcpu)) {
>> + if (kvm_is_error_hva(hva)) {
>> + kvm_incr_pc(vcpu);
>> + ret = 1;
>> + goto out_unlock;
>> + }
>> +
>> + if (fault_status == FSC_PERM) {
>> + /* DC IVAC on a R/O memslot */
>> + kvm_inject_dabt(vcpu,
>> kvm_vcpu_get_hfar(vcpu));
>
> One question:
> In general, the "DC" ops show up very early in guest. So what if the
> guest do this before interrupt initialization? If so, the guest may
> stuck here.
I don't understand your question. Do you mean "what if the guest
does this without being able to handle an exception"?
If that's your question, then the answer is "don't do that".
The architecture is clear that DC IVAC needs write permission, and
will result in an abort being delivered if there is no writable
mapping (and there can't be, the memslot is R/O).
DC CIVAC doesn't have that requirement, and will not generate an
exception.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-01-28 9:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 9:30 [PATCH] arm64/kvm: correct the error report in kvm_handle_guest_abort Jianyong Wu
2021-01-15 11:20 ` Marc Zyngier
2021-01-16 8:46 ` Jianyong Wu
2021-01-18 13:01 ` Jianyong Wu
2021-01-18 13:04 ` Jianyong Wu
2021-01-18 13:26 ` Marc Zyngier
2021-01-18 13:38 ` Jianyong Wu
2021-01-18 13:44 ` Marc Zyngier
2021-01-18 14:24 ` Jianyong Wu
2021-01-26 8:10 ` Jianyong Wu
2021-01-26 9:18 ` Marc Zyngier
2021-01-28 3:01 ` Jianyong Wu
2021-01-28 9:07 ` Marc Zyngier [this message]
2021-01-28 9:55 ` Jianyong Wu
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=f11a46325548ad5b93e24f4cfdb22d65@kernel.org \
--to=maz@kernel.org \
--cc=James.Morse@arm.com \
--cc=Jianyong.Wu@arm.com \
--cc=Justin.He@arm.com \
--cc=Steve.Capper@arm.com \
--cc=Suzuki.Poulose@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=nd@arm.com \
--cc=will@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).