Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp579528ybh; Tue, 21 Jul 2020 02:46:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypeUXwcYi2LMSM0bHICrHTKOmQGYAWN1V/D/AqFdMYujYMAjvpmufrkM9KeyvZCi3yXv5K X-Received: by 2002:a17:906:eb93:: with SMTP id mh19mr23763118ejb.552.1595324769775; Tue, 21 Jul 2020 02:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595324769; cv=none; d=google.com; s=arc-20160816; b=QGtQzrUkPi8A6fRBpRBiCH2dvLJZTlpmW01c6VUl1VyHug4Bi2CqeE/zfL7484Zmco ZoX/oVzRPYrtPtQ6H4nN88xstS9J807u1bU18COFdrIzVxDCBCNnZx/Y5L45OY7wdpVO oz0yva7y2Rx5SioW+k7IvhICzlcoCfOG0rim5LdJ4jFqT6Pfs2WfxJPnSzQ23AAGvLG5 FVw3S4dQ/epZGWeylSkQ1y07WcDq0KXtMzVScRw3XMw5iLKiSm3EouKqhfoO/a62KQC0 UsMCjvod2Ek/iagYjpvibMJP+Ram0JI+hRClK8Xdn757chw3fQqF5g41HtSCHjKu6qsi dtqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VCTmXoCDoueHGgkSs0dR8Q0gxBgF8BRtzs8whbeoPBY=; b=Q6e3rig1p4IVRnGFIB+kcBC9d+6yyt+HxLG51FpuGgaD8SoH46xc/SWRR1+vnOgcuU zV5H8fUss7tjRCC14tlAQpDj8PG5gxKeHAeWtvR8YgLGv53EBmmEdcOYMAfpT3c+HMNF 5hZbshbikLbyBY6kg9O/C1H17hlFBj3q5afOrz3BuMl7Hw+HqqKP0Y61Fa/6T6O1hjny AeHQae8k05cLsD5o0ssIUXfah5DtjgQyEIhe3UQaZIyPdRtHk+GZsoADPkhgQWmQlMw3 /Bv6BAIMiMXTBjCyvJLC0UfiqABXf+rG2HTzdN2wehjnNqJMb5vhaSD+f1r7nGYhqACi zCDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=i7S9t2tE; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n8si12660407edi.222.2020.07.21.02.45.46; Tue, 21 Jul 2020 02:46:09 -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=@google.com header.s=20161025 header.b=i7S9t2tE; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728870AbgGUJpC (ORCPT + 99 others); Tue, 21 Jul 2020 05:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725984AbgGUJpB (ORCPT ); Tue, 21 Jul 2020 05:45:01 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 133B7C061794 for ; Tue, 21 Jul 2020 02:45:01 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id z2so20574255wrp.2 for ; Tue, 21 Jul 2020 02:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VCTmXoCDoueHGgkSs0dR8Q0gxBgF8BRtzs8whbeoPBY=; b=i7S9t2tE6o1ZpRYbBoPLh0mSIFrwHpF9lRxApXBd0SVtfEaMYvKF999IuDfaCE0DdV wFP+lVdRe3oBxP2XXvkxkBId3a9rt+6LPKWVsl+ePCY53KV/eftUkC17hvcyirlr+CGK x7ecwNpbckzsh0wui6eblLsfMr8GEq9ZrWF10CjkBxj2vMY7btc6zTVBhf2gFaf+aYKQ Z9o0w00u6PzL/RWmFmEzV0p9EKWUu+yEx7/TbdTY8Td8Japa4BSiSwPQ6XbmtKjsTrTi vXBWkcRXULUnuwkT7FCat/ZEFHAvwe0oSFvoHGLxUv4FYZhSJU1tk0eMqjkihc349oCz jYCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VCTmXoCDoueHGgkSs0dR8Q0gxBgF8BRtzs8whbeoPBY=; b=gpmFJ4ffkpeG+HEZybcOsGJfIDzW09VBp5B+EmyGJ93jZDlICJ/fIPz47IquqL9HVc 98HuBmJM/t8XMNiiuYY0hJrYkFus85lNgtFm4bI9YzauAy2XhViy4uEBZ0DDzCQy1uOb teq5pgU/p+Uhyd762c8QvFConZofstZ69wBjR/xD16RVWomVxS739cMOr4gGZBhNhmWY EihvNOY8G8SKkVmYubfs8ZOXFAY/bdG6qiVpJk7ig3LkuCSjyVMC+3JNS7cw3siV8mvI 5/6pLK0Ha6Ko8yx4M/VgP1kmdjpO26D8UIZ4lSYZ3C6iWbI0fRKbwtSkAK8YdJOy0cYJ NQ6w== X-Gm-Message-State: AOAM530GUyX5SFykr7mfGEwtj2Uqd9E428u6MSvIDosNmlxkW6673jHC R3t3qEBk2pB6koLySUizFwWNyQ== X-Received: by 2002:adf:f542:: with SMTP id j2mr25975490wrp.61.1595324699596; Tue, 21 Jul 2020 02:44:59 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:cd93:4ca4:af31:19e5]) by smtp.gmail.com with ESMTPSA id l1sm39195773wrb.12.2020.07.21.02.44.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2020 02:44:58 -0700 (PDT) From: David Brazdil To: Marc Zyngier , Will Deacon , Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, kernel-team@android.com, David Brazdil Subject: [PATCH 1/2] KVM: arm64: Make nVHE ASLR conditional on RANDOMIZE_BASE Date: Tue, 21 Jul 2020 10:44:44 +0100 Message-Id: <20200721094445.82184-2-dbrazdil@google.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200721094445.82184-1-dbrazdil@google.com> References: <20200721094445.82184-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If there are spare bits in non-VHE hyp VA, KVM unconditionally replaces them with a random tag chosen at init. Disable this if the kernel is built without RANDOMIZE_BASE to align with kernel behavior. Signed-off-by: David Brazdil --- arch/arm64/kvm/va_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/va_layout.c b/arch/arm64/kvm/va_layout.c index a4f48c1ac28c..e0404bcab019 100644 --- a/arch/arm64/kvm/va_layout.c +++ b/arch/arm64/kvm/va_layout.c @@ -48,7 +48,7 @@ __init void kvm_compute_layout(void) va_mask = GENMASK_ULL(tag_lsb - 1, 0); tag_val = hyp_va_msb; - if (tag_lsb != (vabits_actual - 1)) { + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && tag_lsb != (vabits_actual - 1)) { /* We have some free bits to insert a random tag. */ tag_val |= get_random_long() & GENMASK_ULL(vabits_actual - 2, tag_lsb); } -- 2.27.0