Received: by 2002:a05:6a10:c7d3:0:0:0:0 with SMTP id h19csp618394pxy; Sat, 14 Aug 2021 18:05:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh1bbaNhwEocsul581bOgcG5EDyZe7swICb4F8nk1at5SaN2ZNtKt0GWuNK8x7wQ5sVbNG X-Received: by 2002:a92:d10d:: with SMTP id a13mr7004461ilb.87.1628989527590; Sat, 14 Aug 2021 18:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628989527; cv=none; d=google.com; s=arc-20160816; b=FoUvZQojXlTBVS9AVbX1qlrIxO3aPjvecnMTAmiD2JaKz1HeBsR7aZYODmzlLRTC4E L5u7MDJihyO1iFrx0DVw40opRXu96WVc11Wyy/0mFYfgXIif85qg2/IF/nHYBZOFhWnD CcTfcxnJDAq/rG3bKSSSLAH3YEB4zXxAh3ofTUOG7bxUENffa1wXD3x4QP+UdtQHdXIF 5AIo17cRc4W7AADK2s9r4DFutTwUbcdxA7LD4/u+IE1sSH/2E56snqsrgKmZzY72LIi0 o4AHkTWlKAPRzuSF5kaR7oaMRK5VaPlIqfv5XviRlRgxFlM3QlQBzPr2CcncQa2Usexx W84Q== 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 :dkim-signature; bh=7CuxvVxDOmKp2g5Ri+ZH700zVAyxQXJLrLM9CSY/ZmU=; b=lmFkDTMimH7FTxr7YGwg4z47nKxRMRgQvE6AbX10h17D7kOUxNmNsZ2ceeJRiZ3DPf Hob+HR+I+43Y8yrU1GHB6zEad+SQkFDL5vcCYPV5AOB7evnKxc7iNOM5Pg5AEm10Yg8V XxDikzR47iCjR1yppMQNTFSvPJsdzB1spnSHwbkVqE/4X57UX+gugWs577nk0sUxAjnZ 0Rs76wiGvlm97S2bNvB6UAZtErMqzVyqHSfi4L5u3OO+ZG2fOMLZmhfhJ60ChJAJNZ5S Zllcm57SS4R5pDS4lV7IMZg9enGUVoYJf3ZjcM/i0kZPtxX+zbocqqz5/nrl+KTMbLY4 s1zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LRn8Bok2; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y196si7634580iof.86.2021.08.14.18.05.16; Sat, 14 Aug 2021 18:05:27 -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=@redhat.com header.s=mimecast20190719 header.b=LRn8Bok2; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236638AbhHOBDi (ORCPT + 99 others); Sat, 14 Aug 2021 21:03:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51169 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236646AbhHOBDX (ORCPT ); Sat, 14 Aug 2021 21:03:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628989374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7CuxvVxDOmKp2g5Ri+ZH700zVAyxQXJLrLM9CSY/ZmU=; b=LRn8Bok2NAdI2lsWoKae3GD+rPqZuPn5do3t/W3T08tgf0K3UqirYy+cYxDCWr9NDb8CT6 fxLMvsiiXP8/aW/whMVJt3JoxHaQNNzKWaKl0Z5CUCuokNu/ToU4CjOEqxkDPm8gAAC/s6 9Gqy1lyCr+Er9pYpsZkwUPDGy2bc9ts= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-wUj_VntAMqy6WUa9H6OnnQ-1; Sat, 14 Aug 2021 21:02:53 -0400 X-MC-Unique: wUj_VntAMqy6WUa9H6OnnQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F9F71853025; Sun, 15 Aug 2021 01:02:51 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-103.bne.redhat.com [10.64.54.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 923896091B; Sun, 15 Aug 2021 01:02:45 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.cs.columbia.edu Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, james.morse@arm.com, mark.rutland@arm.com, Jonathan.Cameron@huawei.com, will@kernel.org, maz@kernel.org, pbonzini@redhat.com, vkuznets@redhat.com, shan.gavin@gmail.com Subject: [PATCH v4 12/15] arm64: Detect async PF para-virtualization feature Date: Sun, 15 Aug 2021 08:59:44 +0800 Message-Id: <20210815005947.83699-13-gshan@redhat.com> In-Reply-To: <20210815005947.83699-1-gshan@redhat.com> References: <20210815005947.83699-1-gshan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This implements kvm_para_available() to check if para-virtualization features are available or not. Besides, kvm_para_has_feature() is enhanced to detect the asynchronous page fault para-virtualization feature. These two functions are going to be used by guest kernel to enable the asynchronous page fault. This also adds kernel option (CONFIG_KVM_GUEST), which is the umbrella for the optimizations related to KVM para-virtualization. Signed-off-by: Gavin Shan --- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/kvm_para.h | 12 +++++++++++- arch/arm64/include/uapi/asm/kvm_para.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index fdcd54d39c1e..6dceae6ed7d3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1081,6 +1081,17 @@ config PARAVIRT_TIME_ACCOUNTING If in doubt, say N here. +config KVM_GUEST + bool "KVM Guest Support" + depends on PARAVIRT + default y + help + This option enables various optimizations for running under the KVM + hypervisor. Overhead for the kernel when not running inside KVM should + be minimal. + + In case of doubt, say Y + config KEXEC depends on PM_SLEEP_SMP select KEXEC_CORE diff --git a/arch/arm64/include/asm/kvm_para.h b/arch/arm64/include/asm/kvm_para.h index 0ea481dd1c7a..8f39c60a6619 100644 --- a/arch/arm64/include/asm/kvm_para.h +++ b/arch/arm64/include/asm/kvm_para.h @@ -3,6 +3,8 @@ #define _ASM_ARM_KVM_PARA_H #include +#include +#include static inline bool kvm_check_and_clear_guest_paused(void) { @@ -11,7 +13,12 @@ static inline bool kvm_check_and_clear_guest_paused(void) static inline unsigned int kvm_arch_para_features(void) { - return 0; + unsigned int features = 0; + + if (kvm_arm_hyp_service_available(ARM_SMCCC_KVM_FUNC_ASYNC_PF)) + features |= (1 << KVM_FEATURE_ASYNC_PF); + + return features; } static inline unsigned int kvm_arch_para_hints(void) @@ -21,6 +28,9 @@ static inline unsigned int kvm_arch_para_hints(void) static inline bool kvm_para_available(void) { + if (IS_ENABLED(CONFIG_KVM_GUEST)) + return true; + return false; } diff --git a/arch/arm64/include/uapi/asm/kvm_para.h b/arch/arm64/include/uapi/asm/kvm_para.h index 162325e2638f..70bbc7d1ec75 100644 --- a/arch/arm64/include/uapi/asm/kvm_para.h +++ b/arch/arm64/include/uapi/asm/kvm_para.h @@ -4,6 +4,8 @@ #include +#define KVM_FEATURE_ASYNC_PF 0 + /* Async PF */ #define KVM_ASYNC_PF_ENABLED (1 << 0) #define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1) -- 2.23.0