From: James Morse <james.morse@arm.com>
To: Christoffer Dall <cdall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>,
Punit Agrawal <punit.agrawal@arm.com>,
kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] KVM: arm/arm64: Signal SIGBUS when stage2 discovers hwpoison memory
Date: Fri, 02 Jun 2017 11:16:10 +0100 [thread overview]
Message-ID: <59313AEA.2060705@arm.com> (raw)
In-Reply-To: <20170601222235.GN20919@cbox>
Hi Christoffer,
On 01/06/17 23:22, Christoffer Dall wrote:
> On Wed, May 24, 2017 at 05:32:50PM +0100, James Morse wrote:
>> Once we enable ARCH_SUPPORTS_MEMORY_FAILURE on arm64, notifications for
>> broken memory can call memory_failure() in mm/memory-failure.c to deliver
>> SIGBUS to any user space process using the page, and notify all the
>> in-kernel users.
>>
>> If the page corresponded with guest memory, KVM will unmap this page
>> from its stage2 page tables. The user space process that allocated
>> this memory may have never touched this page in which case it may not
>> be mapped meaning SIGBUS won't be delivered.
> Sorry, I don't remember, what is the scenario where KVM can have a
> mapping in stage 2 without there being a corresponding mapping for user
> space?
(looks like I mean more than one thing by mapping... oops.)
Mapping in that there is a physical page for this user-space address, but when
qemu first touches it, it will be faulted in as its not been touched before.
(rambling on:)
When mm/memory_failure.c:memory_failure() walks the rmap for the poisoned page
it doesn't find qemu, so no user-space processes gets signalled.
If qemu were to touch the page, fixup_user_fault() will return -EHWPOISON and we
deliver sigbus to qemu.
This doesn't happen when the guest touches the page as kvm's core code maps
-EHWPOISON to KVM_PFN_ERR_HWPOISON, which the arm/arm64 kvm code ignores and
drops -EFAULT on userspace instead.
>> This works well until a guest accesses that page, and KVM discovers
>> pfn == KVM_PFN_ERR_HWPOISON when it comes to process the stage2 fault.
>>
>> Do as x86 does, and deliver the SIGBUS when we discover
>> KVM_PFN_ERR_HWPOISON. Use the stage2 mapping size as the si_addr_lsb
>
> But this part about the stage 2 mapping size is not what the code does.
> It uses the granularity of the mmap region, if I'm not mistaken.
Yes. This is what I got wrong last time, Punit put me right, but I forgot to
update the commit message.
I will change this 'Use the'... sentence in v3 to:
> Use the hugepage size as si_addr_lsb if this vma was allocated as a hugepage.
> Transparent hugepages will be split by memory_failure() before we see them
> here.
Thanks,
James
WARNING: multiple messages have this Message-ID (diff)
From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] KVM: arm/arm64: Signal SIGBUS when stage2 discovers hwpoison memory
Date: Fri, 02 Jun 2017 11:16:10 +0100 [thread overview]
Message-ID: <59313AEA.2060705@arm.com> (raw)
In-Reply-To: <20170601222235.GN20919@cbox>
Hi Christoffer,
On 01/06/17 23:22, Christoffer Dall wrote:
> On Wed, May 24, 2017 at 05:32:50PM +0100, James Morse wrote:
>> Once we enable ARCH_SUPPORTS_MEMORY_FAILURE on arm64, notifications for
>> broken memory can call memory_failure() in mm/memory-failure.c to deliver
>> SIGBUS to any user space process using the page, and notify all the
>> in-kernel users.
>>
>> If the page corresponded with guest memory, KVM will unmap this page
>> from its stage2 page tables. The user space process that allocated
>> this memory may have never touched this page in which case it may not
>> be mapped meaning SIGBUS won't be delivered.
> Sorry, I don't remember, what is the scenario where KVM can have a
> mapping in stage 2 without there being a corresponding mapping for user
> space?
(looks like I mean more than one thing by mapping... oops.)
Mapping in that there is a physical page for this user-space address, but when
qemu first touches it, it will be faulted in as its not been touched before.
(rambling on:)
When mm/memory_failure.c:memory_failure() walks the rmap for the poisoned page
it doesn't find qemu, so no user-space processes gets signalled.
If qemu were to touch the page, fixup_user_fault() will return -EHWPOISON and we
deliver sigbus to qemu.
This doesn't happen when the guest touches the page as kvm's core code maps
-EHWPOISON to KVM_PFN_ERR_HWPOISON, which the arm/arm64 kvm code ignores and
drops -EFAULT on userspace instead.
>> This works well until a guest accesses that page, and KVM discovers
>> pfn == KVM_PFN_ERR_HWPOISON when it comes to process the stage2 fault.
>>
>> Do as x86 does, and deliver the SIGBUS when we discover
>> KVM_PFN_ERR_HWPOISON. Use the stage2 mapping size as the si_addr_lsb
>
> But this part about the stage 2 mapping size is not what the code does.
> It uses the granularity of the mmap region, if I'm not mistaken.
Yes. This is what I got wrong last time, Punit put me right, but I forgot to
update the commit message.
I will change this 'Use the'... sentence in v3 to:
> Use the hugepage size as si_addr_lsb if this vma was allocated as a hugepage.
> Transparent hugepages will be split by memory_failure() before we see them
> here.
Thanks,
James
next prev parent reply other threads:[~2017-06-02 10:13 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 16:32 [PATCH v2] KVM: arm/arm64: Signal SIGBUS when stage2 discovers hwpoison memory James Morse
2017-05-24 16:32 ` James Morse
2017-06-01 22:22 ` Christoffer Dall
2017-06-01 22:22 ` Christoffer Dall
2017-06-02 10:16 ` James Morse [this message]
2017-06-02 10:16 ` James Morse
2017-06-02 10:43 ` Christoffer Dall
2017-06-02 10:43 ` Christoffer Dall
2017-06-07 9:41 ` James Morse
2017-06-07 9:41 ` James Morse
2017-06-16 11:32 ` James Morse
2017-06-16 11:32 ` James Morse
2017-06-21 7:42 ` gengdongjiu
2017-06-21 7:42 ` gengdongjiu
2017-06-21 9:53 ` James Morse
2017-06-21 9:53 ` James Morse
2017-06-21 10:59 ` gengdongjiu
2017-06-21 10:59 ` gengdongjiu
2017-06-21 12:44 ` James Morse
2017-06-21 12:44 ` James Morse
2017-06-22 6:47 ` gengdongjiu
2017-06-22 6:47 ` gengdongjiu
2017-06-22 16:39 ` James Morse
2017-06-22 16:39 ` James Morse
2017-06-24 14:56 ` gengdongjiu
2017-06-24 14:56 ` gengdongjiu
2017-06-23 9:38 ` James Morse
2017-06-23 9:38 ` James Morse
2017-06-23 10:18 ` Peter Maydell
2017-06-23 10:18 ` Peter Maydell
2017-06-24 15:07 ` gengdongjiu
2017-06-24 15:07 ` gengdongjiu
2017-06-24 8:23 ` gengdongjiu
2017-06-24 8:23 ` gengdongjiu
2017-06-22 14:49 ` gengdongjiu
2017-06-22 14:49 ` gengdongjiu
2017-06-21 11:12 ` gengdongjiu
2017-06-21 11:12 ` gengdongjiu
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=59313AEA.2060705@arm.com \
--to=james.morse@arm.com \
--cc=cdall@linaro.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
--cc=punit.agrawal@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.