From d32802f0c31b67049384fabf526645106a6397b8 Mon Sep 17 00:00:00 2001
From: Wojciech Macek <wma@FreeBSD.org>
Date: Wed, 31 Jan 2018 06:42:01 +0000
Subject: [PATCH] PowerNV: fix compilation on non-NV platforms

Submitted by:          Wojciech Macek <wma@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies
---
 sys/powerpc/aim/mp_cpudep.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/powerpc/aim/mp_cpudep.c b/sys/powerpc/aim/mp_cpudep.c
index f001bf4c8db5..94f96d596d58 100644
--- a/sys/powerpc/aim/mp_cpudep.c
+++ b/sys/powerpc/aim/mp_cpudep.c
@@ -85,13 +85,15 @@ cpudep_ap_early_bootstrap(void)
 		break;
 	case IBMPOWER8:
 	case IBMPOWER8E:
-		isync();
-		/* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */
-		mtspr(SPR_LPID, 0);
-		isync();
+		if (mfmsr() & PSL_HV) {
+			isync();
+			/* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */
+			mtspr(SPR_LPID, 0);
+			isync();
 
-		mtspr(SPR_LPCR, LPCR_LPES);
-		isync();
+			mtspr(SPR_LPCR, LPCR_LPES);
+			isync();
+		}
 		break;
 	}