Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3546455pxj; Mon, 24 May 2021 09:05:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsJKhArF+RyRvdfKVUD1Kokiucc9wAjSKL62pjM4yv2g21FrFxLxuSApYVZkcx7AczZEK1 X-Received: by 2002:a05:6402:4cf:: with SMTP id n15mr27613006edw.162.1621872354033; Mon, 24 May 2021 09:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872354; cv=none; d=google.com; s=arc-20160816; b=r7I7GesepaE1hZzG0tzMuM4gPX+dBTUBnL2peSrv6sPLfIzX7EvWAlwqA7hsT2WP4N cQnCvgtDODxCOtIXBXZdM1uQ7g2LqwOv0oxCjkvNZOGQjUocgLy1xBR2euP3IQGhPA0U IwNkjnu9dM4KF91AryWZCpBDMW2yg8nRT7pXz2N0uNamH4nZYNNfnxcDQEnL7VakNe/n MeCKkOuI3BAGK+7m36REzPFOuoz48Ypn2KjXTWaKkTsuhHxs6yFKPuzuor3k9RvBaJEU GFPSoF2Psej9yxa6ZdR8PoHjDmntwETWk4xDdjB+6gWXuyoM0kDFgm1LSKKdwk5X8pYF BmYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wrGIGpTaRVh+Ss/0FfrSGTWk3dG+IH3eWZTOV5GImL0=; b=cKTmo3/cQIyC/+kA9vn4AVYp031ld9NE3Px8H+qiTTPegwxXfRfd5VH7js+s3ZNEL6 jXP02UkiS4culDsBiCcJrrLDSIhyM34nWW4+HKO9Ui56hid2Plfk0QOvp+ZbKJ6t310s OO74PNNSqynETaTA+ULmCCm3XG7o7UsJ952ORVxEtft9vkP0ehxM/SnSy2QNZThPkfuB zUEAQjGEJC+/ElwWAu4IkxVC4ELlHPMoLiCzAjVNZEh/6Nj1xmy3Fz3mMk0v1z9319bm ALpq4J5suXQRBu3KxZfAwQLjZJlgFI5ZloZOtZGilSl4GGCswCUcsa2yy+BadCcbctf5 2ynA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PSpy6wmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si13382208edu.237.2021.05.24.09.05.22; Mon, 24 May 2021 09:05:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PSpy6wmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237914AbhEXQFo (ORCPT + 99 others); Mon, 24 May 2021 12:05:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235787AbhEXP7L (ORCPT ); Mon, 24 May 2021 11:59:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 171F06195C; Mon, 24 May 2021 15:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871098; bh=Hkib7HmFjpGuga3aSoohJ7gDsBbzsy2qgzCm9wjyFXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSpy6wmuxtVWllPrYNHHpeWYpGVX1qo1fTyWin+AccAz0j00482fju+EUpG84dlSk FBVLSzLqVQY/qGExIblbCwGPIpMeJMiahDrjC+Po0wlxxDNwDHz0ZY47UlRsXi3bwP r+Ny9pwbpuy1Yf8ZtMt+cyNEB41LhyfCqHsHOTvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Borislav Petkov Subject: [PATCH 5.12 073/127] x86/sev-es: Forward page-faults which happen during emulation Date: Mon, 24 May 2021 17:26:30 +0200 Message-Id: <20210524152337.326764765@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel commit c25bbdb564060adaad5c3a8a10765c13487ba6a3 upstream. When emulating guest instructions for MMIO or IOIO accesses, the #VC handler might get a page-fault and will not be able to complete. Forward the page-fault in this case to the correct handler instead of killing the machine. Fixes: 0786138c78e7 ("x86/sev-es: Add a Runtime #VC Exception Handler") Signed-off-by: Joerg Roedel Signed-off-by: Borislav Petkov Cc: stable@vger.kernel.org # v5.10+ Link: https://lkml.kernel.org/r/20210519135251.30093-3-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/sev-es.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/arch/x86/kernel/sev-es.c +++ b/arch/x86/kernel/sev-es.c @@ -1269,6 +1269,10 @@ static __always_inline void vc_forward_e case X86_TRAP_UD: exc_invalid_op(ctxt->regs); break; + case X86_TRAP_PF: + write_cr2(ctxt->fi.cr2); + exc_page_fault(ctxt->regs, error_code); + break; case X86_TRAP_AC: exc_alignment_check(ctxt->regs, error_code); break;