Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2661271pxb; Sun, 8 Nov 2020 08:40:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrbyUq1YYQ89avLixosjBRrLd6Zl9xjQ/5YP/tJrgEqfVDkBQYTp5MJr7jOwfrzFZUYwTQ X-Received: by 2002:a17:906:16ca:: with SMTP id t10mr11810314ejd.24.1604853607637; Sun, 08 Nov 2020 08:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604853607; cv=none; d=google.com; s=arc-20160816; b=YQeXvnSHklgIGBDsslVDr0HgvP9Oe/STFQ4yW20f69ofEOCp5XAfuZwIGivmsiwpZX 2ZtuaEY0F6MOWwurWqrMTeYtnRpWz9Ib1mtnovNYfKdKGPYKxBap/0bTamZUXJ8deU3Y aMSbd2C9jebNiZh4vBxTHfhhWYeAVyMW2WZMzCZ3K0Q0oQLwVLG5G3XgxxZPlwPPO164 ruJqYdWcRtulyrU+tnTpMzY9+1MeczLCcgxZto2qg+remIO4qnYf153g0tC/CwTtm/fo LLHHGNr/e+N0hrI6/pbaHOOImmst5oWlQcmECxbDDwvRKoF0FbTwY/oBQCqHlwIL6ron jPGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:date:from:sender:dkim-signature; bh=3G7FVwYQRunIazmBCUpjweHyHC3Fn2vVsZDow8nM3EI=; b=h8CxVQWrDAIb7UC2Vfx3waiM4zwJfo0V5qXaRgADpLMbTotpcs0rSHAVk7M03XuINt fUUEH4/rrCiIGFX61NQhhKUzo8HIHLMs/oeyRzfLkZ1U9vGTVAUNwLYaCHomukpEfJsD n8EeHmNueGo+aq9in0TxsXBXOFYLIqmS2ANt6Yiyv5gRUCAaZ09XeUdRX8jC7tM0/Q2C uAwgm40GsnK3UpPFRfx5gSHqLsvgpfrIGG0F8upMh+wxVopPyflwcRtweFEGK3fGtsoT HSUJDnRWpN9ZbQmwAxJSrpEpq9m7ekRWuaOF4Bf/thP9dRkJ2zU1Ansf0XHMbD73jX/L LLqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TydhePct; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si5662942edn.292.2020.11.08.08.39.41; Sun, 08 Nov 2020 08:40:07 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=TydhePct; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728451AbgKHQhU (ORCPT + 99 others); Sun, 8 Nov 2020 11:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728068AbgKHQhU (ORCPT ); Sun, 8 Nov 2020 11:37:20 -0500 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C5AC0613CF for ; Sun, 8 Nov 2020 08:37:18 -0800 (PST) Received: by mail-qk1-x72e.google.com with SMTP id r7so5853509qkf.3 for ; Sun, 08 Nov 2020 08:37:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:mime-version :content-disposition; bh=3G7FVwYQRunIazmBCUpjweHyHC3Fn2vVsZDow8nM3EI=; b=TydhePctclCrzDNbwTETc656ZHJ3OUFBj9ASriIZJeeHKTC0lUA+jd5TVgAmSL2BgO ykmNdtIJXt2Mu//14yXvuiyLWgLv1C9MWDWcGlOjwOzb2Hhuz19k3p20inmbUfZTg8rk xDoQSjFrol1Dko2JvDlW1SWIrdcHhOSy/7fQlLcrwgMqEXkmxuotgljqdn8iKyybFy0R 3jIAB+baH/yC8LDx6D53hx41EsZqc+x8N3QS0hJOYer1z/1Cj4QknbwztlcuLzYkmqYt z0ODjf/ZXb4LpwhY0DEwD/tK2MrZ99dfnM1UoVLxlDjnLyEJPRLOiNJFauASm6aVSKBx TM4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :mime-version:content-disposition; bh=3G7FVwYQRunIazmBCUpjweHyHC3Fn2vVsZDow8nM3EI=; b=VrZr+cEEtdxSgs/8sQmyBKCGrOcUIENRAGUCChteXYYCRoZmreYvshBHBHiXXUwyD4 dO/w4bKMZienbNvhlpEo2aludTjGqJEKDHNSPMIyswl49qLzThxrBvH0XKTtK9wHVF1y hv2Op8LKcWzjj9kAyd61/RaD2UlQPdWRf8/m9MRRrUGdenXABJOLWOnviBjtiL9EO2rw cmqypFjYzGqxorMKFXGeuDeUbguDWlsBI1p4rOep+6eEncYOvRQlMtB2NUFCUDcjqSjy MpVIO4ZmmRLifRPlNrmNexyIKXtygYSYZVOkBsbxdpZa6ufJh+u9bfonOBO4lBcQZbdW sEVQ== X-Gm-Message-State: AOAM532nfxX+MmfVN/e1krSm/C1fu1cwhnjDkZmsdnqZsqLvJwqYWaBt r6uT//SLJL2DKaCL6wx1p5s= X-Received: by 2002:a37:dc02:: with SMTP id v2mr391128qki.181.1604853437836; Sun, 08 Nov 2020 08:37:17 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id u16sm4404250qth.42.2020.11.08.08.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 08:37:16 -0800 (PST) Sender: Arvind Sankar From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Sun, 8 Nov 2020 11:37:15 -0500 To: Tom Lendacky , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: Definition of PMD_FLAGS_DEC_WP in arch/x86/mm/mem_encrypt_identity.c Message-ID: <20201108163715.GA206902@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I have a question about this definition in arch/x86/mm/mem_encrypt_identity.c: #define PMD_FLAGS_LARGE (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL) #define PMD_FLAGS_DEC PMD_FLAGS_LARGE #define PMD_FLAGS_DEC_WP ((PMD_FLAGS_DEC & ~_PAGE_CACHE_MASK) | \ (_PAGE_PAT | _PAGE_PWT)) _PAGE_CACHE_MASK and _PAGE_PAT are for 4k pages, not 2M pages. The definition of PMD_FLAGS_DEC_WP clears the PSE bit by masking out _PAGE_CACHE_MASK, and sets it again by setting _PAGE_PAT, resulting in PMD_FLAGS_DEC_WP actually being write-through, not write-protected, using PAT index 1. Shouldn't the definition be #define PMD_FLAGS_DEC_WP (PMD_FLAGS_DEC | _PAGE_PAT_LARGE | _PAGE_PWT) for write-protected using PAT index 5? I guess the difference doesn't actually matter for encrypt-in-place? But mem_encrypt_boot.S takes pains to initialize PA5 to be write-protected, and it looks like it won't actually be used. Thanks.