From patchwork Thu May 30 15:13:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10968993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58F9C912 for ; Thu, 30 May 2019 15:14:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A7B228915 for ; Thu, 30 May 2019 15:14:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EEEA28BDE; Thu, 30 May 2019 15:14:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C659528BC2 for ; Thu, 30 May 2019 15:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uhbXw5hza/RxliYcd1QtCC431KZjZWbeO9PDEECz1MM=; b=PnfG0P40gQzE7hAL2Fe6JRwFIs KGGbM7uIm5CxIF+/rAlPgqIYphIBkGAmjiaksFBDIR5qDuDWRuS8ZXRSvDg8XnsYwmnuViQlpGUIK Bqxkn74oxZkO6NJ6DZrrttKjM5nf4zHekLkDus/kauBtc2ccmdu8VKax8cG0TgKFHLF1cgMbjNel4 w2Dvjognp21dUjlZlmXXn8+I2mEbtJce+0W0Vw6HqdUvwYYqChTY3QYOugN3KvGP/tKJoO1Y6qSyq 87PrQ68tm4Q+0kL/KIDBqQd+7MhuLCz152FJxrwWKCqDpJUHZWViLAr7BNzd51N+l34wM2kWeSvs2 Jp3cqNUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMkr-00027m-FQ; Thu, 30 May 2019 15:14:09 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMko-00026t-1T for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:07 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DD521341; Thu, 30 May 2019 08:14:04 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 12E773F59C; Thu, 30 May 2019 08:14:02 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 1/9] update_headers.sh: Add missing shell quoting Date: Thu, 30 May 2019 16:13:06 +0100 Message-Id: <1559229194-3036-2-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081406_104993_93416180 X-CRM114-Status: GOOD ( 10.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP update_headers.sh can break if the current working directory has a funny name or if something odd is passed for LINUX_ROOT. In the interest of cleanliness, quote where appropriate. Signed-off-by: Dave Martin Reviewed-by: Andre Przywara --- util/update_headers.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/update_headers.sh b/util/update_headers.sh index 2d93646..4ba1b9f 100755 --- a/util/update_headers.sh +++ b/util/update_headers.sh @@ -11,17 +11,17 @@ if [ "$#" -ge 1 ] then LINUX_ROOT="$1" else - LINUX_ROOT=/lib/modules/$(uname -r)/source + LINUX_ROOT="/lib/modules/$(uname -r)/source" fi -if [ ! -d $LINUX_ROOT/include/uapi/linux ] +if [ ! -d "$LINUX_ROOT/include/uapi/linux" ] then echo "$LINUX_ROOT does not seem to be valid Linux source tree." echo "usage: $0 [path-to-Linux-source-tree]" exit 1 fi -cp $LINUX_ROOT/include/uapi/linux/kvm.h include/linux +cp -- "$LINUX_ROOT/include/uapi/linux/kvm.h" include/linux for arch in arm arm64 mips powerpc x86 do @@ -30,6 +30,6 @@ do arm64) KVMTOOL_PATH=arm/aarch64 ;; *) KVMTOOL_PATH=$arch ;; esac - cp $LINUX_ROOT/arch/$arch/include/uapi/asm/kvm.h \ - $KVMTOOL_PATH/include/asm + cp -- "$LINUX_ROOT/arch/$arch/include/uapi/asm/kvm.h" \ + "$KVMTOOL_PATH/include/asm" done From patchwork Thu May 30 15:13:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10968995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCC78933 for ; Thu, 30 May 2019 15:14:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE3B428BCC for ; Thu, 30 May 2019 15:14:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B255928BDC; Thu, 30 May 2019 15:14:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 63A6328BCC for ; Thu, 30 May 2019 15:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7ETE6NH9FFRW7u0D8x1XQl9zrZYx6MUBs8NqgYu0kLs=; b=EoqEtyXTajK4+za8FTtHotilYv LCDt9p/pFOReoVh6KDEiIQOUjq2gYopQ8tdFi//R67p3pLwFmpHiasZadRyeuYSvOpquBSYFml+nl AvPysdU4Xq5nVYEwDMwESIHlQlK8Z45oiJwPSHfwsizxesD9moocXf7urzNVyATQUKwyv0Yc690Ik cgGsmMBjwXGaY7+2aaoPpEpnqwvJFVpXGtSDuf91T6pgMeyzvIpYoIHQla3PTlUy6fM8gCTyo0J9s rvRQdknExg50YJz0wTcV70LxiLZBEVFG8sYgh+bEw1DRDsznyJI1+Q0hZtpMS5Ujd6RY3U9+TyrQF /SXEMtzA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMl5-0002NA-Eb; Thu, 30 May 2019 15:14:23 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMkp-00027I-3j for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F1BEE15AD; Thu, 30 May 2019 08:14:06 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 26EEC3F59C; Thu, 30 May 2019 08:14:05 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 2/9] update_headers.sh: Cleanly report failure on error Date: Thu, 30 May 2019 16:13:07 +0100 Message-Id: <1559229194-3036-3-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081407_153844_B6580007 X-CRM114-Status: UNSURE ( 9.04 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If in intermediate step fails, update_headers.sh blindly continues and may return success status. To avoid errors going unnoticed when driving this script, exit and report failure status as soon as something goes wrong. For good measure, also fail on expansion of undefined shell variables to aid future maintainers. Signed-off-by: Dave Martin Reviewed-by: Andre Przywara --- util/update_headers.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/update_headers.sh b/util/update_headers.sh index 4ba1b9f..a7e21b8 100755 --- a/util/update_headers.sh +++ b/util/update_headers.sh @@ -7,6 +7,8 @@ # using the lib/modules/`uname -r`/source link. ######################################################################## +set -ue + if [ "$#" -ge 1 ] then LINUX_ROOT="$1" From patchwork Thu May 30 15:13:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10968997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 203D5912 for ; Thu, 30 May 2019 15:14:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1219F28B8B for ; Thu, 30 May 2019 15:14:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 040C428BB9; Thu, 30 May 2019 15:14:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8291C28BD3 for ; Thu, 30 May 2019 15:14:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YOWchE1edZesvoTcNJ1P2Vo52cXbkoXubJkPGgYAhmU=; b=SHXL4Un30SNrHzuGx9ZpxbMYJ5 h2EoAUaimHWsisStH+e2Awd48JNEoc6eaWaUEe7it3KwhOl+YebSA0OGMFykD6s+vjJgQGFmc5OJ8 ta7V4sp6ZgIVyG7Re3LCxt8FejF6az3VJ5IV2vyXzCuEUjNQ0Qg+X47nsDiQ5ZOqqdNcXNKjOjmbP UPTwAV+RUFUrEG47xxFI5weACl/3eX9KHdmydXGZboRONp8VDGUXClnFJGwFKGM0eWIKEI2SpZXMs IyQkQqNXCFOo7hPj4meQ2QRZVbYLvfRfSbWHZCW6LPmIjI2LcVkzXnk4+o+iuIGhmM6qRsTBS+9bM zg1gXhog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMlD-0002UH-36; Thu, 30 May 2019 15:14:31 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMkr-00027l-6U for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 12693341; Thu, 30 May 2019 08:14:09 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3B8153F59C; Thu, 30 May 2019 08:14:07 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 3/9] update_headers.sh: arm64: Copy sve_context.h if available Date: Thu, 30 May 2019 16:13:08 +0100 Message-Id: <1559229194-3036-4-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081409_251190_EE58B410 X-CRM114-Status: GOOD ( 10.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The SVE KVM support for arm64 includes the additional backend header from . So update this header if it is available. To avoid creating a sudden dependency on a specific minimum kernel version, ignore the header if the source kernel tree doesn't have it. Signed-off-by: Dave Martin --- util/update_headers.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/util/update_headers.sh b/util/update_headers.sh index a7e21b8..90d3ead 100755 --- a/util/update_headers.sh +++ b/util/update_headers.sh @@ -25,11 +25,22 @@ fi cp -- "$LINUX_ROOT/include/uapi/linux/kvm.h" include/linux +unset KVMTOOL_PATH + +copy_arm64 () { + local src=$LINUX_ROOT/arch/$arch/include/uapi/asm/sve_context.h + + if [ -e "$src" ] + then + cp -- "$src" "$KVMTOOL_PATH/include/asm" + fi +} + for arch in arm arm64 mips powerpc x86 do case "$arch" in arm) KVMTOOL_PATH=arm/aarch32 ;; - arm64) KVMTOOL_PATH=arm/aarch64 ;; + arm64) KVMTOOL_PATH=arm/aarch64; copy_arm64 ;; *) KVMTOOL_PATH=$arch ;; esac cp -- "$LINUX_ROOT/arch/$arch/include/uapi/asm/kvm.h" \ From patchwork Thu May 30 15:13:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10968999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00EDD912 for ; Thu, 30 May 2019 15:14:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E54C128B8F for ; Thu, 30 May 2019 15:14:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D99DA28AFF; Thu, 30 May 2019 15:14:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0C58628B90 for ; Thu, 30 May 2019 15:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Xj0NtJoXGZ8GQXOUGwbxsnN3NPHGzuxfO5zPJ/yUPC0=; b=Im7jOaWQ4jLEvNdRfxokgGqk7F 2vNUAlg7wSQUrCB1zVPoMh9f+IJ60vt3epLk3qq+ntlaYv0eKbI4Z/I26W/LJfTLhHFwBXQ9tsS+x +rtvWm8lSQU6suOhb7kTACasPjVEbEmmye80ZK0GIymRBhx8mLEbF5dEXxyvk0MpAMMMnLfLEBFKJ L7/hAEHAdtmZYRUtfWkjUeHd53+r6lQMMrCdVaBrv0CQNyfklnbg5vhOuLcRfKqVgieOQOkb4rJyl aUkse5OQpzuXUcwh/rU1owrrtPGs4ngpPPxXA2hMo9xX/XnIYDwj4DZRcz8eoBN5X2akzNIP+qrIq rUyr3bpQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMlL-0002jH-Ru; Thu, 30 May 2019 15:14:39 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMkt-0002AB-8g for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EE078165C; Thu, 30 May 2019 08:14:10 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 502D83F59C; Thu, 30 May 2019 08:14:09 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 4/9] update_headers: Sync kvm UAPI headers with linux v5.1-rc1 Date: Thu, 30 May 2019 16:13:09 +0100 Message-Id: <1559229194-3036-5-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081411_801736_43E44AED X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Pull in upstream UAPI headers, for subsequent arm64 SVE / ptrauth support (among other things). Signed-off-by: Dave Martin Reviewed-by: Andre Przywara --- arm/aarch64/include/asm/kvm.h | 43 ++++++++++++++++++++++++++++ arm/aarch64/include/asm/sve_context.h | 53 +++++++++++++++++++++++++++++++++++ include/linux/kvm.h | 15 ++++++++-- powerpc/include/asm/kvm.h | 48 +++++++++++++++++++++++++++++++ x86/include/asm/kvm.h | 1 + 5 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 arm/aarch64/include/asm/sve_context.h diff --git a/arm/aarch64/include/asm/kvm.h b/arm/aarch64/include/asm/kvm.h index 97c3478..7b7ac0f 100644 --- a/arm/aarch64/include/asm/kvm.h +++ b/arm/aarch64/include/asm/kvm.h @@ -35,6 +35,7 @@ #include #include #include +#include #define __KVM_HAVE_GUEST_DEBUG #define __KVM_HAVE_IRQ_LINE @@ -102,6 +103,9 @@ struct kvm_regs { #define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */ #define KVM_ARM_VCPU_PSCI_0_2 2 /* CPU uses PSCI v0.2 */ #define KVM_ARM_VCPU_PMU_V3 3 /* Support guest PMUv3 */ +#define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */ +#define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */ +#define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */ struct kvm_vcpu_init { __u32 target; @@ -226,6 +230,45 @@ struct kvm_vcpu_events { KVM_REG_ARM_FW | ((r) & 0xffff)) #define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) +/* SVE registers */ +#define KVM_REG_ARM64_SVE (0x15 << KVM_REG_ARM_COPROC_SHIFT) + +/* Z- and P-regs occupy blocks at the following offsets within this range: */ +#define KVM_REG_ARM64_SVE_ZREG_BASE 0 +#define KVM_REG_ARM64_SVE_PREG_BASE 0x400 +#define KVM_REG_ARM64_SVE_FFR_BASE 0x600 + +#define KVM_ARM64_SVE_NUM_ZREGS __SVE_NUM_ZREGS +#define KVM_ARM64_SVE_NUM_PREGS __SVE_NUM_PREGS + +#define KVM_ARM64_SVE_MAX_SLICES 32 + +#define KVM_REG_ARM64_SVE_ZREG(n, i) \ + (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | KVM_REG_ARM64_SVE_ZREG_BASE | \ + KVM_REG_SIZE_U2048 | \ + (((n) & (KVM_ARM64_SVE_NUM_ZREGS - 1)) << 5) | \ + ((i) & (KVM_ARM64_SVE_MAX_SLICES - 1))) + +#define KVM_REG_ARM64_SVE_PREG(n, i) \ + (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | KVM_REG_ARM64_SVE_PREG_BASE | \ + KVM_REG_SIZE_U256 | \ + (((n) & (KVM_ARM64_SVE_NUM_PREGS - 1)) << 5) | \ + ((i) & (KVM_ARM64_SVE_MAX_SLICES - 1))) + +#define KVM_REG_ARM64_SVE_FFR(i) \ + (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | KVM_REG_ARM64_SVE_FFR_BASE | \ + KVM_REG_SIZE_U256 | \ + ((i) & (KVM_ARM64_SVE_MAX_SLICES - 1))) + +#define KVM_ARM64_SVE_VQ_MIN __SVE_VQ_MIN +#define KVM_ARM64_SVE_VQ_MAX __SVE_VQ_MAX + +/* Vector lengths pseudo-register: */ +#define KVM_REG_ARM64_SVE_VLS (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | \ + KVM_REG_SIZE_U512 | 0xffff) +#define KVM_ARM64_SVE_VLS_WORDS \ + ((KVM_ARM64_SVE_VQ_MAX - KVM_ARM64_SVE_VQ_MIN) / 64 + 1) + /* Device Control API: ARM VGIC */ #define KVM_DEV_ARM_VGIC_GRP_ADDR 0 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 diff --git a/arm/aarch64/include/asm/sve_context.h b/arm/aarch64/include/asm/sve_context.h new file mode 100644 index 0000000..754ab75 --- /dev/null +++ b/arm/aarch64/include/asm/sve_context.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* Copyright (C) 2017-2018 ARM Limited */ + +/* + * For use by other UAPI headers only. + * Do not make direct use of header or its definitions. + */ + +#ifndef _UAPI__ASM_SVE_CONTEXT_H +#define _UAPI__ASM_SVE_CONTEXT_H + +#include + +#define __SVE_VQ_BYTES 16 /* number of bytes per quadword */ + +#define __SVE_VQ_MIN 1 +#define __SVE_VQ_MAX 512 + +#define __SVE_VL_MIN (__SVE_VQ_MIN * __SVE_VQ_BYTES) +#define __SVE_VL_MAX (__SVE_VQ_MAX * __SVE_VQ_BYTES) + +#define __SVE_NUM_ZREGS 32 +#define __SVE_NUM_PREGS 16 + +#define __sve_vl_valid(vl) \ + ((vl) % __SVE_VQ_BYTES == 0 && \ + (vl) >= __SVE_VL_MIN && \ + (vl) <= __SVE_VL_MAX) + +#define __sve_vq_from_vl(vl) ((vl) / __SVE_VQ_BYTES) +#define __sve_vl_from_vq(vq) ((vq) * __SVE_VQ_BYTES) + +#define __SVE_ZREG_SIZE(vq) ((__u32)(vq) * __SVE_VQ_BYTES) +#define __SVE_PREG_SIZE(vq) ((__u32)(vq) * (__SVE_VQ_BYTES / 8)) +#define __SVE_FFR_SIZE(vq) __SVE_PREG_SIZE(vq) + +#define __SVE_ZREGS_OFFSET 0 +#define __SVE_ZREG_OFFSET(vq, n) \ + (__SVE_ZREGS_OFFSET + __SVE_ZREG_SIZE(vq) * (n)) +#define __SVE_ZREGS_SIZE(vq) \ + (__SVE_ZREG_OFFSET(vq, __SVE_NUM_ZREGS) - __SVE_ZREGS_OFFSET) + +#define __SVE_PREGS_OFFSET(vq) \ + (__SVE_ZREGS_OFFSET + __SVE_ZREGS_SIZE(vq)) +#define __SVE_PREG_OFFSET(vq, n) \ + (__SVE_PREGS_OFFSET(vq) + __SVE_PREG_SIZE(vq) * (n)) +#define __SVE_PREGS_SIZE(vq) \ + (__SVE_PREG_OFFSET(vq, __SVE_NUM_PREGS) - __SVE_PREGS_OFFSET(vq)) + +#define __SVE_FFR_OFFSET(vq) \ + (__SVE_PREGS_OFFSET(vq) + __SVE_PREGS_SIZE(vq)) + +#endif /* ! _UAPI__ASM_SVE_CONTEXT_H */ diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 6d4ea4b..2fe12b4 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -986,8 +986,13 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 #define KVM_CAP_EXCEPTION_PAYLOAD 164 #define KVM_CAP_ARM_VM_IPA_SIZE 165 -#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 +#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */ #define KVM_CAP_HYPERV_CPUID 167 +#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168 +#define KVM_CAP_PPC_IRQ_XIVE 169 +#define KVM_CAP_ARM_SVE 170 +#define KVM_CAP_ARM_PTRAUTH_ADDRESS 171 +#define KVM_CAP_ARM_PTRAUTH_GENERIC 172 #ifdef KVM_CAP_IRQ_ROUTING @@ -1145,6 +1150,7 @@ struct kvm_dirty_tlb { #define KVM_REG_SIZE_U256 0x0050000000000000ULL #define KVM_REG_SIZE_U512 0x0060000000000000ULL #define KVM_REG_SIZE_U1024 0x0070000000000000ULL +#define KVM_REG_SIZE_U2048 0x0080000000000000ULL struct kvm_reg_list { __u64 n; /* number of regs */ @@ -1211,6 +1217,8 @@ enum kvm_device_type { #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_ITS, #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS + KVM_DEV_TYPE_XIVE, +#define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_MAX, }; @@ -1434,12 +1442,15 @@ struct kvm_enc_region { #define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) #define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) -/* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT */ +/* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */ #define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log) /* Available with KVM_CAP_HYPERV_CPUID */ #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2) +/* Available with KVM_CAP_ARM_SVE */ +#define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) + /* Secure Encrypted Virtualization command */ enum sev_cmd_id { /* Guest initialization commands */ diff --git a/powerpc/include/asm/kvm.h b/powerpc/include/asm/kvm.h index 8c876c1..b0f72de 100644 --- a/powerpc/include/asm/kvm.h +++ b/powerpc/include/asm/kvm.h @@ -463,10 +463,12 @@ struct kvm_ppc_cpu_char { #define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED (1ULL << 58) #define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF (1ULL << 57) #define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS (1ULL << 56) +#define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST (1ull << 54) #define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY (1ULL << 63) #define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR (1ULL << 62) #define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ULL << 61) +#define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE (1ull << 58) /* Per-vcpu XICS interrupt controller state */ #define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c) @@ -480,6 +482,8 @@ struct kvm_ppc_cpu_char { #define KVM_REG_PPC_ICP_PPRI_SHIFT 16 /* pending irq priority */ #define KVM_REG_PPC_ICP_PPRI_MASK 0xff +#define KVM_REG_PPC_VP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x8d) + /* Device control API: PPC-specific devices */ #define KVM_DEV_MPIC_GRP_MISC 1 #define KVM_DEV_MPIC_BASE_ADDR 0 /* 64-bit */ @@ -675,4 +679,48 @@ struct kvm_ppc_cpu_char { #define KVM_XICS_PRESENTED (1ULL << 43) #define KVM_XICS_QUEUED (1ULL << 44) +/* POWER9 XIVE Native Interrupt Controller */ +#define KVM_DEV_XIVE_GRP_CTRL 1 +#define KVM_DEV_XIVE_RESET 1 +#define KVM_DEV_XIVE_EQ_SYNC 2 +#define KVM_DEV_XIVE_GRP_SOURCE 2 /* 64-bit source identifier */ +#define KVM_DEV_XIVE_GRP_SOURCE_CONFIG 3 /* 64-bit source identifier */ +#define KVM_DEV_XIVE_GRP_EQ_CONFIG 4 /* 64-bit EQ identifier */ +#define KVM_DEV_XIVE_GRP_SOURCE_SYNC 5 /* 64-bit source identifier */ + +/* Layout of 64-bit XIVE source attribute values */ +#define KVM_XIVE_LEVEL_SENSITIVE (1ULL << 0) +#define KVM_XIVE_LEVEL_ASSERTED (1ULL << 1) + +/* Layout of 64-bit XIVE source configuration attribute values */ +#define KVM_XIVE_SOURCE_PRIORITY_SHIFT 0 +#define KVM_XIVE_SOURCE_PRIORITY_MASK 0x7 +#define KVM_XIVE_SOURCE_SERVER_SHIFT 3 +#define KVM_XIVE_SOURCE_SERVER_MASK 0xfffffff8ULL +#define KVM_XIVE_SOURCE_MASKED_SHIFT 32 +#define KVM_XIVE_SOURCE_MASKED_MASK 0x100000000ULL +#define KVM_XIVE_SOURCE_EISN_SHIFT 33 +#define KVM_XIVE_SOURCE_EISN_MASK 0xfffffffe00000000ULL + +/* Layout of 64-bit EQ identifier */ +#define KVM_XIVE_EQ_PRIORITY_SHIFT 0 +#define KVM_XIVE_EQ_PRIORITY_MASK 0x7 +#define KVM_XIVE_EQ_SERVER_SHIFT 3 +#define KVM_XIVE_EQ_SERVER_MASK 0xfffffff8ULL + +/* Layout of EQ configuration values (64 bytes) */ +struct kvm_ppc_xive_eq { + __u32 flags; + __u32 qshift; + __u64 qaddr; + __u32 qtoggle; + __u32 qindex; + __u8 pad[40]; +}; + +#define KVM_XIVE_EQ_ALWAYS_NOTIFY 0x00000001 + +#define KVM_XIVE_TIMA_PAGE_OFFSET 0 +#define KVM_XIVE_ESB_PAGE_OFFSET 4 + #endif /* __LINUX_KVM_POWERPC_H */ diff --git a/x86/include/asm/kvm.h b/x86/include/asm/kvm.h index dabfcf7..7a0e64c 100644 --- a/x86/include/asm/kvm.h +++ b/x86/include/asm/kvm.h @@ -381,6 +381,7 @@ struct kvm_sync_regs { #define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0) #define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) #define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) +#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 From patchwork Thu May 30 15:13:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10969001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02CC5933 for ; Thu, 30 May 2019 15:14:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E71EC28B80 for ; Thu, 30 May 2019 15:14:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAA4C28BCA; Thu, 30 May 2019 15:14:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 63D6F28928 for ; Thu, 30 May 2019 15:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n8vC2FWsWtVQK09N84bGrrWtc175RU6OAsPgWKo3hV8=; b=RknldgEA2D+eiwwR3PJj6dGuxD FBcN7qdagtnlT98w7KXj6Alh60YvcdKP5qu28nDQL0VFoUCHnmkvWvCe10K+DrcI25m6c0FsMJXbK EtzOMFbwkN5uEu5WIdej/JCFino7PnHkaKyD78nL/qkqPgc8jSgUCUceebYHlD792aeT/N6ubtrJP 9TFezzEs0K3ESFPxi/OBG5jQJ8/YgSA9QLRMYYtnztzpA82rj+EtFR7JG0ByGlH84579Y7RTYojRd C+7oGWNepD93HeYhDcLemaxrBPsy1jTXg79qB7DwDl8GcyvVf1owkGPY5gahsl8V76KD7T4P1T7FS nyN8KX0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMlX-0002xa-5U; Thu, 30 May 2019 15:14:51 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMkv-0002Cg-62 for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D59C9341; Thu, 30 May 2019 08:14:12 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 37CD33F59C; Thu, 30 May 2019 08:14:11 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 5/9] KVM: arm/arm64: Add a vcpu feature for pointer authentication Date: Thu, 30 May 2019 16:13:10 +0100 Message-Id: <1559229194-3036-6-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081413_668359_81E73F96 X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Amit Daniel Kachhap This patch adds a runtime capabality for KVM tool to enable Arm64 8.3 Pointer Authentication in guest kernel. Two vcpu features KVM_ARM_VCPU_PTRAUTH_[ADDRESS/GENERIC] are supplied together to enable Pointer Authentication in KVM guest after checking the capability. Command line options --enable-ptrauth and --disable-ptrauth are added to use this feature. However, if those options are not provided then also this feature is enabled if host supports this capability. The macros defined in the headers are not in sync and should be replaced from the upstream. Signed-off-by: Amit Daniel Kachhap Signed-off-by: Dave Martin [merge new kernel heaers] --- arm/aarch32/include/kvm/kvm-cpu-arch.h | 2 ++ arm/aarch64/include/kvm/kvm-config-arch.h | 6 +++++- arm/aarch64/include/kvm/kvm-cpu-arch.h | 3 +++ arm/include/arm-common/kvm-config-arch.h | 2 ++ arm/kvm-cpu.c | 20 ++++++++++++++++++-- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/arm/aarch32/include/kvm/kvm-cpu-arch.h b/arm/aarch32/include/kvm/kvm-cpu-arch.h index d28ea67..3ec6f03 100644 --- a/arm/aarch32/include/kvm/kvm-cpu-arch.h +++ b/arm/aarch32/include/kvm/kvm-cpu-arch.h @@ -13,4 +13,6 @@ #define ARM_CPU_ID 0, 0, 0 #define ARM_CPU_ID_MPIDR 5 +#define ARM_VCPU_PTRAUTH_FEATURE 0 + #endif /* KVM__KVM_CPU_ARCH_H */ diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index 04be43d..0279b13 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -8,7 +8,11 @@ "Create PMUv3 device"), \ OPT_U64('\0', "kaslr-seed", &(cfg)->kaslr_seed, \ "Specify random seed for Kernel Address Space " \ - "Layout Randomization (KASLR)"), + "Layout Randomization (KASLR)"), \ + OPT_BOOLEAN('\0', "enable-ptrauth", &(cfg)->enable_ptrauth, \ + "Enables pointer authentication"), \ + OPT_BOOLEAN('\0', "disable-ptrauth", &(cfg)->disable_ptrauth, \ + "Disables pointer authentication"), #include "arm-common/kvm-config-arch.h" diff --git a/arm/aarch64/include/kvm/kvm-cpu-arch.h b/arm/aarch64/include/kvm/kvm-cpu-arch.h index a9d8563..9fa99fb 100644 --- a/arm/aarch64/include/kvm/kvm-cpu-arch.h +++ b/arm/aarch64/include/kvm/kvm-cpu-arch.h @@ -17,4 +17,7 @@ #define ARM_CPU_CTRL 3, 0, 1, 0 #define ARM_CPU_CTRL_SCTLR_EL1 0 +#define ARM_VCPU_PTRAUTH_FEATURE ((1UL << KVM_ARM_VCPU_PTRAUTH_ADDRESS) \ + | (1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC)) + #endif /* KVM__KVM_CPU_ARCH_H */ diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 5734c46..1b4287d 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -10,6 +10,8 @@ struct kvm_config_arch { bool aarch32_guest; bool has_pmuv3; u64 kaslr_seed; + bool enable_ptrauth; + bool disable_ptrauth; enum irqchip_type irqchip; u64 fw_addr; }; diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index 7780251..acd1d5f 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -68,6 +68,18 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_PSCI_0_2); } + /* Check Pointer Authentication command line arguments. */ + if (kvm->cfg.arch.enable_ptrauth && kvm->cfg.arch.disable_ptrauth) + die("Both enable-ptrauth and disable-ptrauth option cannot be present"); + /* + * Always enable Pointer Authentication if system supports + * this extension unless disable-ptrauth option is present. + */ + if (kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS) && + kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC) && + !kvm->cfg.arch.disable_ptrauth) + vcpu_init.features[0] |= ARM_VCPU_PTRAUTH_FEATURE; + /* * If the preferred target ioctl is successful then * use preferred target else try each and every target type @@ -106,8 +118,12 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) die("Unable to find matching target"); } - if (err || target->init(vcpu)) - die("Unable to initialise vcpu"); + if (err || target->init(vcpu)) { + if (kvm->cfg.arch.enable_ptrauth) + die("Unable to initialise vcpu with pointer authentication feature"); + else + die("Unable to initialise vcpu"); + } coalesced_offset = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO); From patchwork Thu May 30 15:13:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10969003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C324933 for ; Thu, 30 May 2019 15:15:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0DE928AFA for ; Thu, 30 May 2019 15:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E52CE28BBD; Thu, 30 May 2019 15:15:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7258B28AFA for ; Thu, 30 May 2019 15:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UD+lvn8QK2ELjBM3H+Fz5A0+eeZRckLgJG19kwoPvcY=; b=DJYtjwTLM728bjrfkc6/am+Sbn nsI+BBGfQNPExx0d17qFxM0TtKDriQoDnIxdxgmPzUOppQ79ofEOIv/l+be1blXZjzVNkav2mJH5L QT7HKzUmVr6PUxqZH5i4nFXGE3U8Uwp63a2iUFxlhTBo5KtqEqU8jjdMvVGF/IvK/806uNP5AJk9Y 2PHUsUnh+3oziJw12bBO0APa1MPylYDe5JAr879mk/48iM0iuK3QbdDwPyAI9sShwWHiK7eC1CeSX 9ERrxnTAtZ+5boPBFQ7FslONprSlKKxj0/IaG6mTHePqhRICRKyFSCCTa03ZOvM49fVcfJBII4eUT DcI5dGug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMlg-0003Bo-AQ; Thu, 30 May 2019 15:15:00 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMkw-0002FV-TS for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BED0D15AD; Thu, 30 May 2019 08:14:14 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1F45E3F59C; Thu, 30 May 2019 08:14:12 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 6/9] arm/arm64: Factor out ptrauth vcpu feature setup Date: Thu, 30 May 2019 16:13:11 +0100 Message-Id: <1559229194-3036-7-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081415_202213_548648C2 X-CRM114-Status: GOOD ( 15.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In the interest of readability, factor out the vcpu feature setup for ptrauth into a separate function. Also, because aarch32 doesn't have this feature or the related command line options anyway, move the actual code into aarch64/. Since ARM_VCPU_PTRAUTH_FEATURE is only there to make the ptrauth feature setup code compile on arm, it is no longer needed: inline and remove it. Signed-off-by: Dave Martin --- arm/aarch32/include/kvm/kvm-cpu-arch.h | 3 ++- arm/aarch64/include/kvm/kvm-cpu-arch.h | 3 +-- arm/aarch64/kvm-cpu.c | 22 ++++++++++++++++++++++ arm/kvm-cpu.c | 12 +----------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/arm/aarch32/include/kvm/kvm-cpu-arch.h b/arm/aarch32/include/kvm/kvm-cpu-arch.h index 3ec6f03..01983f0 100644 --- a/arm/aarch32/include/kvm/kvm-cpu-arch.h +++ b/arm/aarch32/include/kvm/kvm-cpu-arch.h @@ -13,6 +13,7 @@ #define ARM_CPU_ID 0, 0, 0 #define ARM_CPU_ID_MPIDR 5 -#define ARM_VCPU_PTRAUTH_FEATURE 0 +static inline void kvm_cpu__select_features(struct kvm *kvm, + struct kvm_vcpu_init *init) { } #endif /* KVM__KVM_CPU_ARCH_H */ diff --git a/arm/aarch64/include/kvm/kvm-cpu-arch.h b/arm/aarch64/include/kvm/kvm-cpu-arch.h index 9fa99fb..e6875fc 100644 --- a/arm/aarch64/include/kvm/kvm-cpu-arch.h +++ b/arm/aarch64/include/kvm/kvm-cpu-arch.h @@ -17,7 +17,6 @@ #define ARM_CPU_CTRL 3, 0, 1, 0 #define ARM_CPU_CTRL_SCTLR_EL1 0 -#define ARM_VCPU_PTRAUTH_FEATURE ((1UL << KVM_ARM_VCPU_PTRAUTH_ADDRESS) \ - | (1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC)) +void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init); #endif /* KVM__KVM_CPU_ARCH_H */ diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index 0aaefaf..d3c32e0 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -128,6 +128,28 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu) } } +static void select_ptrauth_feature(struct kvm *kvm, struct kvm_vcpu_init *init) +{ + /* Check Pointer Authentication command line arguments. */ + if (kvm->cfg.arch.enable_ptrauth && kvm->cfg.arch.disable_ptrauth) + die("Both enable-ptrauth and disable-ptrauth option cannot be present"); + /* + * Always enable Pointer Authentication if system supports + * this extension unless disable-ptrauth option is present. + */ + if (kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS) && + kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC) && + !kvm->cfg.arch.disable_ptrauth) { + init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_ADDRESS; + init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC; + } +} + +void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) +{ + select_ptrauth_feature(kvm, init); +} + void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu) { if (vcpu->kvm->cfg.arch.aarch32_guest) diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index acd1d5f..764fb05 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -68,17 +68,7 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_PSCI_0_2); } - /* Check Pointer Authentication command line arguments. */ - if (kvm->cfg.arch.enable_ptrauth && kvm->cfg.arch.disable_ptrauth) - die("Both enable-ptrauth and disable-ptrauth option cannot be present"); - /* - * Always enable Pointer Authentication if system supports - * this extension unless disable-ptrauth option is present. - */ - if (kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS) && - kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC) && - !kvm->cfg.arch.disable_ptrauth) - vcpu_init.features[0] |= ARM_VCPU_PTRAUTH_FEATURE; + kvm_cpu__select_features(kvm, &vcpu_init); /* * If the preferred target ioctl is successful then From patchwork Thu May 30 15:13:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10969005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC15F933 for ; Thu, 30 May 2019 15:16:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA98528BD3 for ; Thu, 30 May 2019 15:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE86E28B80; Thu, 30 May 2019 15:16:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64C8B201A4 for ; Thu, 30 May 2019 15:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=5l9QhqKRg06QhuhJYI22HZ8cn/V+L68kdUmFZkhl0nk=; b=aTVH5hM5q9AhcBq9z1gi2d+e1q UD3iS6d4UOaSbdW2Nbn+rNZtPSGMbaqP4YVpoitFHKSR2TtQD50SQydbuht4jZZ5tlRWiZCuf1nWX XVhST/NBu6RRNLjNxovwDmXBOONm4v0eUFNRYIHtYBg5+RCcUtAJDqREvl3hzI94lfg7lWHutuFr9 yWX0LlwHNXtd3urBrHFAkR8lEHrO7zPHO0s8NZVnQbPQbkL8+yC4JrHEVeZydF2NyrWYaRaiRxMay qpfKSvzjFfftwyeGY6Ed+SNYfRSl95g7R0VRIIfaZ1dAVUYM+XcehdjvNfS30RXscEe7GpVD06B7E xbal0u3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMml-0004nZ-5f; Thu, 30 May 2019 15:16:07 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMky-0002I1-SA for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:19 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A4FF2341; Thu, 30 May 2019 08:14:16 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 071863F59C; Thu, 30 May 2019 08:14:14 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 7/9] arm64: Make ptrauth enable/disable diagnostics more user-friendly Date: Thu, 30 May 2019 16:13:12 +0100 Message-Id: <1559229194-3036-8-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081417_182611_E00B1ACC X-CRM114-Status: GOOD ( 17.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To help the user understand what is going on, amend ptrauth configuration diagnostic messages to refer to command line options by the exact name used on the command line. Also, provide a clean diagnostic when ptrauth is requested, but not availble. The generic "Unable to initialise vcpu" message is rather cryptic for this case. Since we now don't attempt to enable ptrauth at all unless KVM reports the relevant capabilities, remove the error message for that case too: in any case, we can't diagnose precisely why KVM_ARM_VCPU_INIT failed, so the message may be misleading. Signed-off-by: Dave Martin --- arm/aarch64/include/kvm/kvm-config-arch.h | 4 ++-- arm/aarch64/kvm-cpu.c | 15 +++++++++++---- arm/kvm-cpu.c | 8 ++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index 0279b13..fe1699d 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -10,9 +10,9 @@ "Specify random seed for Kernel Address Space " \ "Layout Randomization (KASLR)"), \ OPT_BOOLEAN('\0', "enable-ptrauth", &(cfg)->enable_ptrauth, \ - "Enables pointer authentication"), \ + "Enable pointer authentication for the guest"), \ OPT_BOOLEAN('\0', "disable-ptrauth", &(cfg)->disable_ptrauth, \ - "Disables pointer authentication"), + "Disable pointer authentication for the guest"), #include "arm-common/kvm-config-arch.h" diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index d3c32e0..08e4fd5 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -130,16 +130,23 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu) static void select_ptrauth_feature(struct kvm *kvm, struct kvm_vcpu_init *init) { + bool supported; + /* Check Pointer Authentication command line arguments. */ if (kvm->cfg.arch.enable_ptrauth && kvm->cfg.arch.disable_ptrauth) - die("Both enable-ptrauth and disable-ptrauth option cannot be present"); + die("--enable-ptrauth conflicts with --disable-ptrauth"); + + supported = kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS) && + kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC); + + if (kvm->cfg.arch.enable_ptrauth && !supported) + die("--enable-ptrauth not supported on this host"); + /* * Always enable Pointer Authentication if system supports * this extension unless disable-ptrauth option is present. */ - if (kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS) && - kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC) && - !kvm->cfg.arch.disable_ptrauth) { + if (supported && !kvm->cfg.arch.disable_ptrauth) { init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_ADDRESS; init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC; } diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index 764fb05..1652f6f 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -108,12 +108,8 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) die("Unable to find matching target"); } - if (err || target->init(vcpu)) { - if (kvm->cfg.arch.enable_ptrauth) - die("Unable to initialise vcpu with pointer authentication feature"); - else - die("Unable to initialise vcpu"); - } + if (err || target->init(vcpu)) + die("Unable to initialise vcpu"); coalesced_offset = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO); From patchwork Thu May 30 15:13:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10969007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B13DA15E6 for ; Thu, 30 May 2019 15:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A15E128BD5 for ; Thu, 30 May 2019 15:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95AC428BD7; Thu, 30 May 2019 15:16:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F3DA828BDE for ; Thu, 30 May 2019 15:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=s6nvjs4Xn4Z3+SgqaIS+D7vRX5vdivjFNx3/BbKbtTc=; b=Lzn+3NFQ4N+Gg+svusXGUzImHM 8iyrwriOfA9UmK/uT9TJYzuivcfwA6DiazzRmmKHfdwcu+WwA9HqVPEZEzWzzFWY0slOd2LVhAJPm ks+J8yBJ7t2o4YvZF9XznG+b55zygrfxOtT0Z4q58Fk1ELxNgSlHhBHeaz8KTtrhXaz1sy6f4N3ZL Be9nVZaqsJDeDkbugGOA69Y7tj1wFIzDuNrS8E/QjnF2AcnfCCO83KdfncMOQhQd+zK3IkH1sw3Xd C84n6TEEPBEZBAtni2niMiEVdh4zNad46Wk4evJGkiV1iP0rOJU3sZiI2406IxQxiPW7D6mvgk1t9 iCTG+OJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMmq-0004u5-6A; Thu, 30 May 2019 15:16:12 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMl0-0002K0-PS for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8CAB5165C; Thu, 30 May 2019 08:14:18 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E2E493F59C; Thu, 30 May 2019 08:14:16 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 8/9] arm64: Add SVE support Date: Thu, 30 May 2019 16:13:13 +0100 Message-Id: <1559229194-3036-9-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081419_022380_BDBE180C X-CRM114-Status: GOOD ( 16.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds --enable-sve/--disable-sve command line options to allow the user to control whether the Scalable Vector Extension is made available to the guest. This requires use of the new KVM_ARM_VCPU_FINALIZE ioctl before the vcpu is runnable, so a new hook kvm_cpu__configure_features() is added to provide an appropriate place to do this work. By default, SVE is enabled for the guest if the host supports it. Signed-off-by: Dave Martin --- arm/aarch32/include/kvm/kvm-cpu-arch.h | 4 +++ arm/aarch64/include/kvm/kvm-config-arch.h | 6 ++++- arm/aarch64/include/kvm/kvm-cpu-arch.h | 1 + arm/aarch64/kvm-cpu.c | 41 +++++++++++++++++++++++++++++++ arm/include/arm-common/kvm-config-arch.h | 2 ++ arm/kvm-cpu.c | 3 +++ 6 files changed, 56 insertions(+), 1 deletion(-) diff --git a/arm/aarch32/include/kvm/kvm-cpu-arch.h b/arm/aarch32/include/kvm/kvm-cpu-arch.h index 01983f0..780e0e2 100644 --- a/arm/aarch32/include/kvm/kvm-cpu-arch.h +++ b/arm/aarch32/include/kvm/kvm-cpu-arch.h @@ -15,5 +15,9 @@ static inline void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) { } +static inline int kvm_cpu__configure_features(struct kvm_cpu *vcpu) +{ + return 0; +} #endif /* KVM__KVM_CPU_ARCH_H */ diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index fe1699d..41e9d05 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -12,7 +12,11 @@ OPT_BOOLEAN('\0', "enable-ptrauth", &(cfg)->enable_ptrauth, \ "Enable pointer authentication for the guest"), \ OPT_BOOLEAN('\0', "disable-ptrauth", &(cfg)->disable_ptrauth, \ - "Disable pointer authentication for the guest"), + "Disable pointer authentication for the guest"), \ + OPT_BOOLEAN('\0', "enable-sve", &(cfg)->enable_sve, \ + "Enable SVE for the guest"), \ + OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \ + "Disable SVE for the guest"), #include "arm-common/kvm-config-arch.h" diff --git a/arm/aarch64/include/kvm/kvm-cpu-arch.h b/arm/aarch64/include/kvm/kvm-cpu-arch.h index e6875fc..8dfb82e 100644 --- a/arm/aarch64/include/kvm/kvm-cpu-arch.h +++ b/arm/aarch64/include/kvm/kvm-cpu-arch.h @@ -18,5 +18,6 @@ #define ARM_CPU_CTRL_SCTLR_EL1 0 void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init); +int kvm_cpu__configure_features(struct kvm_cpu *vcpu); #endif /* KVM__KVM_CPU_ARCH_H */ diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index 08e4fd5..cdfb22e 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -152,9 +152,50 @@ static void select_ptrauth_feature(struct kvm *kvm, struct kvm_vcpu_init *init) } } +static void select_sve_feature(struct kvm *kvm, struct kvm_vcpu_init *init) +{ + bool supported; + + if (kvm->cfg.arch.enable_sve && kvm->cfg.arch.disable_sve) + die("--enable-sve conflicts with --disable-sve"); + + supported = kvm__supports_extension(kvm, KVM_CAP_ARM_SVE); + + if (kvm->cfg.arch.enable_sve && !supported) + die("--enable-sve not supported on this host"); + + /* Default SVE to on if available and not explicitly disabled */ + if (supported && !kvm->cfg.arch.disable_sve) { + kvm->cfg.arch.enable_sve = true; + init->features[0] |= 1UL << KVM_ARM_VCPU_SVE; + } +} + void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) { select_ptrauth_feature(kvm, init); + select_sve_feature(kvm, init); +} + +static int configure_sve(struct kvm_cpu *vcpu) +{ + int feature = KVM_ARM_VCPU_SVE; + + if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) { + pr_err("KVM_ARM_VCPU_FINALIZE: %s", strerror(errno)); + return -1; + } + + return 0; +} + +int kvm_cpu__configure_features(struct kvm_cpu *vcpu) +{ + if (vcpu->kvm->cfg.arch.enable_sve) + if (configure_sve(vcpu)) + return -1; + + return 0; } void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu) diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 1b4287d..40e3d1f 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -10,6 +10,8 @@ struct kvm_config_arch { bool aarch32_guest; bool has_pmuv3; u64 kaslr_seed; + bool enable_sve; + bool disable_sve; bool enable_ptrauth; bool disable_ptrauth; enum irqchip_type irqchip; diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index 1652f6f..554414f 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -124,6 +124,9 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) vcpu->cpu_compatible = target->compatible; vcpu->is_running = true; + if (kvm_cpu__configure_features(vcpu)) + die("Unable to configure requested vcpu features"); + return vcpu; } From patchwork Thu May 30 15:13:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10969009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A51D515E6 for ; Thu, 30 May 2019 15:16:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 965A52899F for ; Thu, 30 May 2019 15:16:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89D3628B80; Thu, 30 May 2019 15:16:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E00912899F for ; Thu, 30 May 2019 15:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=PaJbz45h6WuU/sNwx3ytWZFGUj2c6USnnfGwY/EDlzk=; b=XWaSEq5s9WaVKFNjVP7szl/sLy BDwYu9zIEdhclU2m0RW2SsW65uSpjTdINoqn1V28LJjBn36jT9U0ujCuz/pkxq0oD6LHGdpNonAwh UYpVDL0vyxDxl5eFEeRQI1PZsU5utI5yvU1rLvwjA1nRZqryk3DhXmYpou7qEPJTcS6DRk0qqyUDe dVoN8Sc8rZ/jfBd4cwm50rURRCdkrzO81q49Wq2Rstz6ZP57I9gmlQvrp4jP9ztHUzGUCPqd8eKiP gLoYmxgN92zrioDYymTp+SE5P+huGFYQZRNXC8rRcNcrRHOS3UH5aGSdLJcNRTjlG1bWCmlQ0QHq6 57mCEL8w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMn0-00058T-MJ; Thu, 30 May 2019 15:16:22 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWMl2-0002I1-Nn for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2019 15:14:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 74780341; Thu, 30 May 2019 08:14:20 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CA8013F59C; Thu, 30 May 2019 08:14:18 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH kvmtool v3 9/9] arm64: Select SVE vector lengths via the command line Date: Thu, 30 May 2019 16:13:14 +0100 Message-Id: <1559229194-3036-10-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> References: <1559229194-3036-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190530_081420_820611_CD4BC646 X-CRM114-Status: GOOD ( 19.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , Marc Zyngier , Andre Przywara , Will Deacon , Kristina Martsenko , Zhang Lei , Amit Daniel Kachhap , =?utf-8?q?Alex_Benn=C3=A9e?= , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support use cases such as migration, it may be important in some situations to restrict the set of SVE vector lengths available to the guest. It can also be useful to observe the behaviour of guest OSes with different vector lengths. To enable testing and experimentation for such configurations, this patch adds a command-line option to allow setting of the set of vector lengths to be made available to the guest. For now, the setting is global: no means is offered to configure individual guest vcpus independently of each other. By default all vector lengths that the host can support are given to the guest, as before. Signed-off-by: Dave Martin --- arm/aarch64/include/kvm/kvm-config-arch.h | 8 +++- arm/aarch64/kvm-cpu.c | 80 ++++++++++++++++++++++++++++++- arm/include/arm-common/kvm-config-arch.h | 1 + 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/arm/aarch64/include/kvm/kvm-config-arch.h b/arm/aarch64/include/kvm/kvm-config-arch.h index 41e9d05..a996612 100644 --- a/arm/aarch64/include/kvm/kvm-config-arch.h +++ b/arm/aarch64/include/kvm/kvm-config-arch.h @@ -1,6 +1,8 @@ #ifndef KVM__KVM_CONFIG_ARCH_H #define KVM__KVM_CONFIG_ARCH_H +int sve_vls_parser(const struct option *opt, const char *arg, int unset); + #define ARM_OPT_ARCH_RUN(cfg) \ OPT_BOOLEAN('\0', "aarch32", &(cfg)->aarch32_guest, \ "Run AArch32 guest"), \ @@ -16,7 +18,11 @@ OPT_BOOLEAN('\0', "enable-sve", &(cfg)->enable_sve, \ "Enable SVE for the guest"), \ OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \ - "Disable SVE for the guest"), + "Disable SVE for the guest"), \ + OPT_CALLBACK('\0', "sve-vls", &(cfg)->sve_vqs, \ + "comma-separated list of vector lengths, in 128-bit units", \ + "Set of vector lengths to enable for the guest", \ + sve_vls_parser, NULL), #include "arm-common/kvm-config-arch.h" diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c index cdfb22e..2c624c3 100644 --- a/arm/aarch64/kvm-cpu.c +++ b/arm/aarch64/kvm-cpu.c @@ -1,8 +1,13 @@ +#include +#include +#include + #include "kvm/kvm-cpu.h" #include "kvm/kvm.h" #include "kvm/virtio.h" #include +#include #define COMPAT_PSR_F_BIT 0x00000040 #define COMPAT_PSR_I_BIT 0x00000080 @@ -12,6 +17,65 @@ #define SCTLR_EL1_E0E_MASK (1 << 24) #define SCTLR_EL1_EE_MASK (1 << 25) +/* + * Work around old kernel headers that lack these definitions in + * : + */ +#ifndef SVE_VQ_MIN +#define SVE_VQ_MIN 1 +#endif + +#ifndef SVE_VQ_MAX +#define SVE_VQ_MAX 512 +#endif + +int sve_vls_parser(const struct option *opt, const char *arg, int unset) +{ + size_t offset = 0; + int vq, n, t; + u64 (*vqs)[(SVE_VQ_MAX + 1 - SVE_VQ_MIN + 63) / 64]; + u64 **cfg_vqs = opt->value; + + if (*cfg_vqs) { + pr_err("sve-vls: SVE vector lengths set may only be specified once"); + return -1; + } + + vqs = calloc(1, sizeof *vqs); + if (!vqs) + die("%s", strerror(ENOMEM)); + + offset = 0; + while (arg[offset]) { + n = -1; + + t = sscanf(arg + offset, + offset == 0 ? "%i%n" : ",%i%n", + &vq, &n); + if (t == EOF || t < 1 || n <= 0) { + pr_err("sve-vls: Comma-separated list of vector lengths required"); + goto error; + } + + if (vq < SVE_VQ_MIN || vq > SVE_VQ_MAX) { + pr_err("sve-vls: Invalid vector length %d", vq); + goto error; + } + + vq -= SVE_VQ_MIN; + (*vqs)[vq / 64] |= (u64)1 << (vq % 64); + + offset += n; + } + + *cfg_vqs = *vqs; + return 0; + +error: + free(vqs); + return -1; +} + static __u64 __core_reg_id(__u64 offset) { __u64 id = KVM_REG_ARM64 | KVM_REG_ARM_CORE | offset; @@ -180,6 +244,16 @@ void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init) static int configure_sve(struct kvm_cpu *vcpu) { int feature = KVM_ARM_VCPU_SVE; + struct kvm_one_reg r = { + .id = KVM_REG_ARM64_SVE_VLS, + .addr = (u64)vcpu->kvm->cfg.arch.sve_vqs, + }; + + if (vcpu->kvm->cfg.arch.sve_vqs) + if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &r)) { + pr_err("Cannot set requested SVE vector lengths"); + return -1; + } if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) { pr_err("KVM_ARM_VCPU_FINALIZE: %s", strerror(errno)); @@ -191,9 +265,13 @@ static int configure_sve(struct kvm_cpu *vcpu) int kvm_cpu__configure_features(struct kvm_cpu *vcpu) { - if (vcpu->kvm->cfg.arch.enable_sve) + if (vcpu->kvm->cfg.arch.enable_sve) { if (configure_sve(vcpu)) return -1; + } else { + if (vcpu->kvm->cfg.arch.sve_vqs) + pr_warning("SVE vector lengths ignored"); + } return 0; } diff --git a/arm/include/arm-common/kvm-config-arch.h b/arm/include/arm-common/kvm-config-arch.h index 40e3d1f..b45201f 100644 --- a/arm/include/arm-common/kvm-config-arch.h +++ b/arm/include/arm-common/kvm-config-arch.h @@ -12,6 +12,7 @@ struct kvm_config_arch { u64 kaslr_seed; bool enable_sve; bool disable_sve; + u64 *sve_vqs; bool enable_ptrauth; bool disable_ptrauth; enum irqchip_type irqchip;