Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3426650pxf; Mon, 29 Mar 2021 01:46:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKvOM8OnDmbST5jj+DiCti9DuFJ60SiVt2usXB79i1LuQXDmqkseweW+fMtVgi+/maiIUX X-Received: by 2002:a17:906:82c5:: with SMTP id a5mr28067167ejy.232.1617007567330; Mon, 29 Mar 2021 01:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007567; cv=none; d=google.com; s=arc-20160816; b=0Id3TtZdl1iyFtxMavBceklKFZOFhL2negqnt36qqSkA0yBxI7IkRxiboKEeqW8qkb tU+pjWNrEwH8RnqnkjnEflZ9GB9Dpi58PaMbQ3oYdAwWdvfGDNJ/ZlAGbx3FZT9Mdgpw gOpCWsUQRWuTU0lMMYv1nzTZUbdxZRg/UOfqVstgmABzBWMfvd/f49P1jc16zyw2E/OT jkKUni5CGy3aZi52odhjoQAqTHWJf80hBkKGwmEVX9P5k1S9bt/7kFa8EMeO/ct6gjpF 4KLh32/+sDdOZ1LdWaLOhGH1mk1iwIGnqOtqDuCQeBsKso7YquFKbYNxZ4bSkIJJ2F+L 4Cow== 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=MxBVM1fzpSHbwdZOXDAXYRwHAHBGse4dDYoNwJ8Em+g=; b=ZBUBuLngfYtALeqv9pfp/tKxal5PsNnZtUrT58Z3Joyfgc0wy8I/SQRIhHQVZj71E6 ydJVw7qOpcS2iBDFqePuNdkbhBgPDNhq9BubLv7d0SDSbHnQuW4S3nApWQT1oQ/KMiwz 1Yd+rxA3yhz0B7Itig+mFFM7QnUDAtQYiH4Y3HWWXERbr6qEVrzxiv975/iPHPD8aNlu HM5yCCKDzE+b3eE7ouwP+4VfJ7imaZss1OLlW+Y7yj+dNYhq95Nllb8h+Ip25ivp1eiY izp9eGj2kvl7R5Nef4qRHHzuUqvhvcorvB79ZoyWB6/+XPQdNtP/wiA4X8/gy4RDTNxE UXjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="SClb2Jp/"; 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 e1si12407186ejq.139.2021.03.29.01.45.45; Mon, 29 Mar 2021 01:46:07 -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="SClb2Jp/"; 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 S234700AbhC2IoI (ORCPT + 99 others); Mon, 29 Mar 2021 04:44:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:41252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbhC2I0e (ORCPT ); Mon, 29 Mar 2021 04:26:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 49262619C1; Mon, 29 Mar 2021 08:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006350; bh=jDaxwurOAMo41ggXWSfxUng3tmQmN0UDPAc2n7ZuL4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SClb2Jp/feONwY9eUp9hzsNEDPYxJcdwGfIPLkblz9A3bAVvoDlri86tXHr2XjK4t VjrAzOOeFpnbXVv/KdTvtBKe5jlWs/32hYBFIYpwupNaMH4iYQaNNRY/bIwEZvcDMQ 1mu6Du7tmDET59ONtf1NjympeAeNi8qbuh5ovX8Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Isaku Yamahata , Borislav Petkov , "Kirill A. Shutemov" , Tom Lendacky Subject: [PATCH 5.10 208/221] x86/mem_encrypt: Correct physical address calculation in __set_clr_pte_enc() Date: Mon, 29 Mar 2021 09:58:59 +0200 Message-Id: <20210329075636.053789669@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Isaku Yamahata commit 8249d17d3194eac064a8ca5bc5ca0abc86feecde upstream. The pfn variable contains the page frame number as returned by the pXX_pfn() functions, shifted to the right by PAGE_SHIFT to remove the page bits. After page protection computations are done to it, it gets shifted back to the physical address using page_level_shift(). That is wrong, of course, because that function determines the shift length based on the level of the page in the page table but in all the cases, it was shifted by PAGE_SHIFT before. Therefore, shift it back using PAGE_SHIFT to get the correct physical address. [ bp: Rewrite commit message. ] Fixes: dfaaec9033b8 ("x86: Add support for changing memory encryption attribute in early boot") Signed-off-by: Isaku Yamahata Signed-off-by: Borislav Petkov Reviewed-by: Kirill A. Shutemov Reviewed-by: Tom Lendacky Cc: Link: https://lkml.kernel.org/r/81abbae1657053eccc535c16151f63cd049dcb97.1616098294.git.isaku.yamahata@intel.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/mem_encrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -231,7 +231,7 @@ static void __init __set_clr_pte_enc(pte if (pgprot_val(old_prot) == pgprot_val(new_prot)) return; - pa = pfn << page_level_shift(level); + pa = pfn << PAGE_SHIFT; size = page_level_size(level); /*