Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4244781pxj; Wed, 12 May 2021 00:56:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOXVPOQ+ceRFh2cN3wa09z8d8MJv8SVP1muKIT7K3+GNfo/uwXY4IDebAOwYdvh6eTG9bP X-Received: by 2002:a92:3002:: with SMTP id x2mr31672855ile.116.1620806188065; Wed, 12 May 2021 00:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620806188; cv=none; d=google.com; s=arc-20160816; b=LC3Jmps1h0qhOy4c2DZ2vuqIIKqcufFkGrHjWuLFZ9oq8iCVXZYDaFAM5tiuESkyGS F2yQIpHUr6Uh5Jr8UPoKVwwqf90SXQd/lRW7bahkRFKK9bcE2+EQPVQiE+QWqpUVVA93 6rGI/rOeGPbaielsWgUBTn2pgPqtk1HYmb+Kt4P9CQyJCI0L6hC5JsulNMfrOyykG4qs fxiolhVGYXz195KMOXBZuYIluMw5/R+1Kazm4sQAcKmM/moqLae/oaAuZA8YhyuHBPHT OxC8vn4N4UWoBWfY09h1A1FRjP2XBFDey1LEK5XNKBhhwJjNg9UT287SiieN/NP/pU9k YhGA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JZI04R8cU0W2J8JsGbqfPdSHwE4rgfkjIxj5PO2oGf8=; b=RgOLevfmQCTLH6vKjtEr70atVAs7qxlt576hghmkQjC3OKGBtYHLMqX1RD+hrF7mvp S4qRFWqnKY13lw+lmbZofTjEsKNtepZsEcygIgWs0uYVr4EJCZDBa8TdOjapnqKFC4Qr WkUjbE4aE6DPz1otJHwpxvO0H17ccRxyAn1B0MwtFhURxhikXo50YkDwIAcj6jZ4Slye w6m7A2DKxhBLG0qzPVRVuV92fHrrtEoYPsRNNUv5P6K18uMuRG1j9pLjeYO8JPJuSzsE ItN3CsAmRx9xcaymCbkTv9stbX+TmJUMLkKjbhm2W8Ets+x/e6AvwBnImGEJ2vq/gq+5 YNqA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x7si26639094jat.98.2021.05.12.00.56.15; Wed, 12 May 2021 00:56:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbhELH43 (ORCPT + 99 others); Wed, 12 May 2021 03:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbhELH4U (ORCPT ); Wed, 12 May 2021 03:56:20 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A32CC06174A; Wed, 12 May 2021 00:55:12 -0700 (PDT) Received: from cap.home.8bytes.org (p549ad305.dip0.t-ipconnect.de [84.154.211.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id A32B141D; Wed, 12 May 2021 09:55:09 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org, Hyunwook Baek Cc: Joerg Roedel , Joerg Roedel , stable@vger.kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , Arvind Sankar , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 4/6] Revert "x86/sev-es: Handle string port IO to kernel memory properly" Date: Wed, 12 May 2021 09:54:43 +0200 Message-Id: <20210512075445.18935-5-joro@8bytes.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512075445.18935-1-joro@8bytes.org> References: <20210512075445.18935-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel This reverts commit 7024f60d655272bd2ca1d3a4c9e0a63319b1eea1. The commit reverted here introduces a short-cut into the #VC handlers memory access code which only works reliably in task context. But the kernels #VC handler can be invoked from any context, making the access_ok() call trigger a warning with CONFIG_DEBUG_ATOMIC_SLEEP enabled. Also the memcpy() used in the reverted patch is wrong, as it has no page-fault handling. Access to kernel memory can also fault due to kernel bugs, and those should not be reported as faults from the #VC handler but as bugs of their real call-site, which is correctly later done from vc_forward_exception(). Fixes: 7024f60d6552 ("x86/sev-es: Handle string port IO to kernel memory properly") Cc: stable@vger.kernel.org # v5.11 Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c index 110b39345b40..f4f319004713 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -333,12 +333,6 @@ static enum es_result vc_write_mem(struct es_em_ctxt *ctxt, u16 d2; u8 d1; - /* If instruction ran in kernel mode and the I/O buffer is in kernel space */ - if (!user_mode(ctxt->regs) && !access_ok(target, size)) { - memcpy(dst, buf, size); - return ES_OK; - } - switch (size) { case 1: memcpy(&d1, buf, 1); @@ -388,12 +382,6 @@ static enum es_result vc_read_mem(struct es_em_ctxt *ctxt, u16 d2; u8 d1; - /* If instruction ran in kernel mode and the I/O buffer is in kernel space */ - if (!user_mode(ctxt->regs) && !access_ok(s, size)) { - memcpy(buf, src, size); - return ES_OK; - } - switch (size) { case 1: if (__get_user(d1, s)) -- 2.31.1