Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit196f878

Browse files
James MorseMarc Zyngier
James Morse
authored and
Marc Zyngier
committed
KVM: arm/arm64: Signal SIGBUS when stage2 discovers hwpoison memory
Once we enable ARCH_SUPPORTS_MEMORY_FAILURE on arm64, notifications forbroken memory can call memory_failure() in mm/memory-failure.c to offlinepages of memory, possibly signalling user space processes and notifying allthe in-kernel users.memory_failure() has two modes, early and late. Early is used bymachine-managers like Qemu to receive a notification when a memory error isnotified to the host. These can then be relayed to the guest before theaffected page is accessed. To enable this, the process must setPR_MCE_KILL_EARLY in PR_MCE_KILL_SET using the prctl() syscall.Once the early notification has been handled, nothing stops themachine-manager or guest from accessing the affected page. If themachine-manager does this the page will fail to be mapped and SIGBUS willbe sent. This patch adds the equivalent path for when the guest accessesthe page, sending SIGBUS to the machine-manager.These two signals can be distinguished by the machine-manager using theirsi_code: BUS_MCEERR_AO for 'action optional' early notifications, andBUS_MCEERR_AR for 'action required' synchronous/late notifications.Do as x86 does, and deliver the SIGBUS when we discover pfn ==KVM_PFN_ERR_HWPOISON. Use the hugepage size as si_addr_lsb if this vma wasallocated as a hugepage. Transparent hugepages will be split bymemory_failure() before we see them here.Cc: Punit Agrawal <punit.agrawal@arm.com>Signed-off-by: James Morse <james.morse@arm.com>Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent02d50cd commit196f878

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎virt/kvm/arm/mmu.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include<linux/kvm_host.h>
2121
#include<linux/io.h>
2222
#include<linux/hugetlb.h>
23+
#include<linux/sched/signal.h>
2324
#include<trace/events/kvm.h>
2425
#include<asm/pgalloc.h>
2526
#include<asm/cacheflush.h>
@@ -1261,6 +1262,24 @@ static void coherent_cache_guest_page(struct kvm_vcpu *vcpu, kvm_pfn_t pfn,
12611262
__coherent_cache_guest_page(vcpu,pfn,size);
12621263
}
12631264

1265+
staticvoidkvm_send_hwpoison_signal(unsigned longaddress,
1266+
structvm_area_struct*vma)
1267+
{
1268+
siginfo_tinfo;
1269+
1270+
info.si_signo=SIGBUS;
1271+
info.si_errno=0;
1272+
info.si_code=BUS_MCEERR_AR;
1273+
info.si_addr= (void__user*)address;
1274+
1275+
if (is_vm_hugetlb_page(vma))
1276+
info.si_addr_lsb=huge_page_shift(hstate_vma(vma));
1277+
else
1278+
info.si_addr_lsb=PAGE_SHIFT;
1279+
1280+
send_sig_info(SIGBUS,&info,current);
1281+
}
1282+
12641283
staticintuser_mem_abort(structkvm_vcpu*vcpu,phys_addr_tfault_ipa,
12651284
structkvm_memory_slot*memslot,unsigned longhva,
12661285
unsigned longfault_status)
@@ -1330,6 +1349,10 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
13301349
smp_rmb();
13311350

13321351
pfn=gfn_to_pfn_prot(kvm,gfn,write_fault,&writable);
1352+
if (pfn==KVM_PFN_ERR_HWPOISON) {
1353+
kvm_send_hwpoison_signal(hva,vma);
1354+
return0;
1355+
}
13331356
if (is_error_noslot_pfn(pfn))
13341357
return-EFAULT;
13351358

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp