linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Ganesh Goudar <ganeshgr@linux.ibm.com>
To: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org
Cc: mahesh@linux.vnet.ibm.com, Ganesh Goudar <ganeshgr@linux.ibm.com>
Subject: [PATCH 2/2] powerpc/mce: Do not poison the memory using guest effective addr
Date: Mon, 27 Apr 2020 11:43:08 +0530	[thread overview]
Message-ID: <20200427061308.26204-2-ganeshgr@linux.ibm.com> (raw)
In-Reply-To: <20200427061308.26204-1-ganeshgr@linux.ibm.com>

As of now, if we hit UE due to memory failure in guest, host MCE
handler tries to find the pfn or physical address where the memory
error occurred using guest effective address and uses that pfn to
poison the memory, which is not right.

If we hit UE in guest, do not try to find pfn in host and thereby
avoid poisoning the memory in host.

Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
---
 arch/powerpc/kernel/mce_power.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
index 143e79450e93..4e541dd3af0d 100644
--- a/arch/powerpc/kernel/mce_power.c
+++ b/arch/powerpc/kernel/mce_power.c
@@ -471,6 +471,10 @@ static int mce_handle_ierror(struct pt_regs *regs,
 				table[i].error_type == MCE_ERROR_TYPE_UE) {
 				unsigned long pfn;
 
+#ifdef CONFIG_KVM_BOOK3S_HANDLER
+				if (get_paca()->kvm_hstate.in_guest)
+					return handled;
+#endif
 				if (get_paca()->in_mce < MAX_MCE_DEPTH) {
 					pfn = addr_to_pfn(regs, regs->nip);
 					if (pfn != ULONG_MAX) {
@@ -515,6 +519,7 @@ static int mce_handle_derror(struct pt_regs *regs,
 		 */
 		if (found)
 			continue;
+		found = 1;
 
 		/* now fill in mce_error_info */
 		mce_err->error_type = table[i].error_type;
@@ -528,6 +533,10 @@ static int mce_handle_derror(struct pt_regs *regs,
 			*addr = regs->dar;
 		else if (mce_err->sync_error &&
 				table[i].error_type == MCE_ERROR_TYPE_UE) {
+#ifdef CONFIG_KVM_BOOK3S_HANDLER
+			if (get_paca()->kvm_hstate.in_guest)
+				continue;
+#endif
 			/*
 			 * We do a maximum of 4 nested MCE calls, see
 			 * kernel/exception-64s.h
@@ -536,7 +545,6 @@ static int mce_handle_derror(struct pt_regs *regs,
 				mce_find_instr_ea_and_phys(regs, addr,
 							   phys_addr);
 		}
-		found = 1;
 	}
 
 	if (found)
-- 
2.17.2


      reply	other threads:[~2020-04-27  6:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27  6:13 [PATCH 1/2] powerpc/mce: Add helper functions to remove duplicate code Ganesh Goudar
2020-04-27  6:13 ` Ganesh Goudar [this message]

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=20200427061308.26204-2-ganeshgr@linux.ibm.com \
    --to=ganeshgr@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=mpe@ellerman.id.au \
    /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).