Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1441796ybt; Thu, 25 Jun 2020 06:17:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw42+WQkfn4RJyMU1CCdDsPATthj6tpS091KD0MJEeYVarM+s5S/MHkrKu+znFSVBGGtiA4 X-Received: by 2002:a50:88e1:: with SMTP id d88mr32116306edd.74.1593091041134; Thu, 25 Jun 2020 06:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593091041; cv=none; d=google.com; s=arc-20160816; b=LPz4nfz3E7lkxF74EHJ3M4MaPmSea7LeQYwDS+OW1fRBcsPPVHVA/d3xSnzZESnHzT YCVGe+k5f3f3/A87WlGsy97B9UAegDpRSdcxXl4v0kbkspVEi+3dGKuYLPH0ShgkNQOH JMU55MeBK2wABmZl07Ar6uzQbRkrSXUM377piEiNkAFY3O7G+TBiZu3A8a71jcWxDCsQ FzZkoNGXOqzZMiuRpWoIIyBTvqG0gHC4v17r399OVNezMnHV5HyoAxDyIVkptinRlsKO lBPlDiKOERQzufrIdVoKc9Kt/oJSNzqmOzYv0TKCo0+RLAchtz/qDYa9caTbvYSBBmc4 kOQg== 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=wraev6ZBkvjCXqVdZoeks0aAoF06EDUQslGWSfcwelE=; b=z0zKnC9TH5UebU6kNBqRaMZZYoVjAQWXfkK3uotuizZZa1TjfAQaMBDgxGdwtmUEfF RRoJ9q/Eg3P/lXoBubViKWE1yL4NCFCf79BF3Fi/5wybEDLVGy4iB56YTApZ0cJwxOhR RLICnAWGUNsdqxRnf/O6JREPq9KfcgwcxAoIzYt6m8iJ8KwFDbNWDs66g52XaPqmbbVA OJ/rMA7mnPjpcx1Lh1JSJd1uxgaFe6mHnoKytMAawQ2A6apA8WZ0P3R5v4u/ttNoZVr8 iUJUYAmcpWjeCH/6JC/burzwbWScq/mZ1ZfOY5jWeBjh5Hkt0SjzvIkX/KCpC7zRRdkN b7Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ua7P+YZJ; 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 cn1si9618226edb.354.2020.06.25.06.16.57; Thu, 25 Jun 2020 06:17:21 -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=ua7P+YZJ; 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 S2404912AbgFYNOi (ORCPT + 99 others); Thu, 25 Jun 2020 09:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404884AbgFYNOd (ORCPT ); Thu, 25 Jun 2020 09:14:33 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAD16C08C5C1 for ; Thu, 25 Jun 2020 06:14:32 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id a6so6715451wmm.0 for ; Thu, 25 Jun 2020 06:14:32 -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=wraev6ZBkvjCXqVdZoeks0aAoF06EDUQslGWSfcwelE=; b=ua7P+YZJwVqfWDyuPBaOjCABX1tSBuIIGIhiG1M2l3I9pUVwlIpIaLg4tk1vR6DAEh xQUnQ2orukTjqBWFut7xqaSuDXy3DXYDlYGhTELnZtsUvD/Cd3xIEN/CKH74JI9PA6Nd rKmturGSVa/8/WsP6oa76tKofsgGbvmi2qPtMaPE9UnhUkfeIXrHGwoUuXQLnVbgGfCp ucEEpOl318TFEhm1s0ykC4Twr8wGoZHtkpkL58rV/Y3cfXmvJcJiWP/Ry9azYYe//N5v mJmJzCEebK98IQhJoPjkGbS7E29bK4nED+seNPErBGhKnMyITD3dUnEHtjk8780W46ud Motg== 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=wraev6ZBkvjCXqVdZoeks0aAoF06EDUQslGWSfcwelE=; b=gTEtCvZmy2V488ooiTKj6HAwfxG4/HLqz5aSXWeC4FTLCQ0feeu1qpHp3CoUBhDmRs t3tVRFFWVG/s1L9Q5IMplL5JlTG38nlYXcdkpjUxanYyHN5qWgXUSPJdx3CTcUb9grUx W7qiSh7iw102LIGRhIM+M5UopKM7HfustZ05GA1dEdtHSen5LBkC1XwTIC+6xell2UT/ FeE3bv5qjfHl/gS9zpVusD/4HcPMcb2JFSz9mtwGddc23LzkZWWHomIJzV3b7BAbRV79 kQKI74NBBfU89Rc0V3ysiGpiDaBLsfWNkze5HX5sPqXtEVKj+ipAujZ3Gii/fMyHUXZg q0lg== X-Gm-Message-State: AOAM53329WX5YxeUoy7Ieir57SdSa2NE74qqYGdu9r3BPYriy4dwwlmH v38sWTrmcYvMZITaqz312Pobxg== X-Received: by 2002:a1c:a3c5:: with SMTP id m188mr3259403wme.152.1593090871469; Thu, 25 Jun 2020 06:14:31 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:c126:6748:7a9d:2d]) by smtp.gmail.com with ESMTPSA id 30sm28006922wrm.74.2020.06.25.06.14.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Jun 2020 06:14:30 -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 v4 04/15] arm64: kvm: Use build-time defines in has_vhe() Date: Thu, 25 Jun 2020 14:14:09 +0100 Message-Id: <20200625131420.71444-5-dbrazdil@google.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200625131420.71444-1-dbrazdil@google.com> References: <20200625131420.71444-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 Build system compiles hyp code with macros specifying if the code belongs to VHE or nVHE. Use these macros to evaluate has_vhe() at compile time. Signed-off-by: David Brazdil --- arch/arm64/include/asm/virt.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h index 5051b388c654..09977acc007d 100644 --- a/arch/arm64/include/asm/virt.h +++ b/arch/arm64/include/asm/virt.h @@ -85,10 +85,17 @@ static inline bool is_kernel_in_hyp_mode(void) static __always_inline bool has_vhe(void) { - if (cpus_have_final_cap(ARM64_HAS_VIRT_HOST_EXTN)) + /* + * The following macros are defined for code specic to VHE/nVHE. + * If has_vhe() is inlined into those compilation units, it can + * be determined statically. Otherwise fall back to caps. + */ + if (__is_defined(__KVM_VHE_HYPERVISOR__)) return true; - - return false; + else if (__is_defined(__KVM_NVHE_HYPERVISOR__)) + return false; + else + return cpus_have_final_cap(ARM64_HAS_VIRT_HOST_EXTN); } #endif /* __ASSEMBLY__ */ -- 2.27.0