From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B388C4167B for ; Tue, 8 Dec 2020 17:27:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE843207D8 for ; Tue, 8 Dec 2020 17:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730617AbgLHR1S (ORCPT ); Tue, 8 Dec 2020 12:27:18 -0500 Received: from foss.arm.com ([217.140.110.172]:52226 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729086AbgLHR1R (ORCPT ); Tue, 8 Dec 2020 12:27:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 982841FB; Tue, 8 Dec 2020 09:26:31 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.29.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DCD4F3F68F; Tue, 8 Dec 2020 09:26:29 -0800 (PST) Date: Tue, 8 Dec 2020 17:26:28 +0000 From: Mark Rutland To: Marc Zyngier Cc: David Brazdil , kvmarm@lists.cs.columbia.edu, James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 1/6] kvm: arm64: Prevent use of invalid PSCI v0.1 function IDs Message-ID: <20201208172628.GB18222@C02TD0UTHF1T.local> References: <20201208142452.87237-1-dbrazdil@google.com> <20201208142452.87237-2-dbrazdil@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 08, 2020 at 03:56:39PM +0000, Marc Zyngier wrote: > On 2020-12-08 14:24, David Brazdil wrote: > > PSCI driver exposes a struct containing the PSCI v0.1 function IDs > > configured in the DT. However, the struct does not convey the > > information whether these were set from DT or contain the default value > > zero. This could be a problem for PSCI proxy in KVM protected mode. > > > > Extend config passed to KVM with a bit mask with individual bits set > > depending on whether the corresponding function pointer in psci_ops is > > set, eg. set bit for PSCI_CPU_SUSPEND if psci_ops.cpu_suspend != NULL. > > > > Previously config was split into multiple global variables. Put > > everything into a single struct for convenience. > > > > Reported-by: Mark Rutland > > Signed-off-by: David Brazdil > > --- > > arch/arm64/include/asm/kvm_host.h | 20 +++++++++++ > > arch/arm64/kvm/arm.c | 14 +++++--- > > arch/arm64/kvm/hyp/nvhe/psci-relay.c | 53 +++++++++++++++++++++------- > > 3 files changed, 70 insertions(+), 17 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h > > b/arch/arm64/include/asm/kvm_host.h > > index 11beda85ee7e..828d50d40dc2 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -240,6 +241,25 @@ struct kvm_host_data { > > struct kvm_pmu_events pmu_events; > > }; > > > > +#define KVM_HOST_PSCI_0_1_CPU_SUSPEND BIT(0) > > +#define KVM_HOST_PSCI_0_1_CPU_ON BIT(1) > > +#define KVM_HOST_PSCI_0_1_CPU_OFF BIT(2) > > +#define KVM_HOST_PSCI_0_1_MIGRATE BIT(3) > > + > > +struct kvm_host_psci_config { > > + /* PSCI version used by host. */ > > + u32 version; > > + > > + /* Function IDs used by host if version is v0.1. */ > > + struct psci_0_1_function_ids function_ids_0_1; > > + > > + /* Bitmask of functions enabled for v0.1, bits KVM_HOST_PSCI_0_1_*. */ > > + unsigned int enabled_functions_0_1; > > Nit: the conventional type for bitmaps is 'unsigned long'. > Also, "enabled" seems odd. Isn't it actually "available"? Sure, that or "implemented" works here. Since there are only 4 functions here, it might make sense to use independent bools rather than a bitmap, which might make this a bit simpler... > > get_psci_0_1_function_ids(); > > + kvm_host_psci_config.version = psci_ops.get_version(); > > + > > + if (kvm_host_psci_config.version == PSCI_VERSION(0, 1)) { > > + kvm_host_psci_config.function_ids_0_1 = get_psci_0_1_function_ids(); > > + kvm_host_psci_config.enabled_functions_0_1 = > > + (psci_ops.cpu_suspend ? KVM_HOST_PSCI_0_1_CPU_SUSPEND : 0) | > > + (psci_ops.cpu_off ? KVM_HOST_PSCI_0_1_CPU_OFF : 0) | > > + (psci_ops.cpu_on ? KVM_HOST_PSCI_0_1_CPU_ON : 0) | > > + (psci_ops.migrate ? KVM_HOST_PSCI_0_1_MIGRATE : 0); ... since e.g. this could be roughly: kvm_host_psci_config.cpu_suspend_implemented = psci_ops.cpu_suspend; kvm_host_psci_config.cpu_off_implemented = psci_ops.cpu_off; kvm_host_psci_config.cpu_on_implemented = psci_ops.cpu_on; kvm_host_psci_config.migrate_implemented = psci_ops.migrate; > > +static inline bool is_psci_0_1_cpu_suspend(u64 func_id) > > +{ > > + return is_psci_0_1_function_enabled(KVM_HOST_PSCI_0_1_CPU_SUSPEND) && > > + (func_id == kvm_host_psci_config.function_ids_0_1.cpu_suspend); > > +} ...and similarly: return kvm_host_psci_config.cpu_suspend_implemented && func_id == kvm_host_psci_config.function_ids_0_1.cpu_suspend) > Otherwise looks OK. Don't bother respinning the series for my > comments, I can tidy things up as I apply it if there are no other > issues. FWIW, I'm happy with whatever choose to do here, so don't feel like you have to follow my suggestions above. Thanks, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48304C4361B for ; Tue, 8 Dec 2020 17:26:37 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id B4E4523AFB for ; Tue, 8 Dec 2020 17:26:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4E4523AFB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 05F704B14B; Tue, 8 Dec 2020 12:26:36 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ACTr650haY-f; Tue, 8 Dec 2020 12:26:34 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C6ADD4B12A; Tue, 8 Dec 2020 12:26:34 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 85DB14B12A for ; Tue, 8 Dec 2020 12:26:33 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eikEFnDcjX8w for ; Tue, 8 Dec 2020 12:26:32 -0500 (EST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 13DEF4B128 for ; Tue, 8 Dec 2020 12:26:32 -0500 (EST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 982841FB; Tue, 8 Dec 2020 09:26:31 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.29.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DCD4F3F68F; Tue, 8 Dec 2020 09:26:29 -0800 (PST) Date: Tue, 8 Dec 2020 17:26:28 +0000 From: Mark Rutland To: Marc Zyngier Subject: Re: [PATCH 1/6] kvm: arm64: Prevent use of invalid PSCI v0.1 function IDs Message-ID: <20201208172628.GB18222@C02TD0UTHF1T.local> References: <20201208142452.87237-1-dbrazdil@google.com> <20201208142452.87237-2-dbrazdil@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: kernel-team@android.com, Catalin Marinas , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Will Deacon , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Tue, Dec 08, 2020 at 03:56:39PM +0000, Marc Zyngier wrote: > On 2020-12-08 14:24, David Brazdil wrote: > > PSCI driver exposes a struct containing the PSCI v0.1 function IDs > > configured in the DT. However, the struct does not convey the > > information whether these were set from DT or contain the default value > > zero. This could be a problem for PSCI proxy in KVM protected mode. > > > > Extend config passed to KVM with a bit mask with individual bits set > > depending on whether the corresponding function pointer in psci_ops is > > set, eg. set bit for PSCI_CPU_SUSPEND if psci_ops.cpu_suspend != NULL. > > > > Previously config was split into multiple global variables. Put > > everything into a single struct for convenience. > > > > Reported-by: Mark Rutland > > Signed-off-by: David Brazdil > > --- > > arch/arm64/include/asm/kvm_host.h | 20 +++++++++++ > > arch/arm64/kvm/arm.c | 14 +++++--- > > arch/arm64/kvm/hyp/nvhe/psci-relay.c | 53 +++++++++++++++++++++------- > > 3 files changed, 70 insertions(+), 17 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h > > b/arch/arm64/include/asm/kvm_host.h > > index 11beda85ee7e..828d50d40dc2 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -240,6 +241,25 @@ struct kvm_host_data { > > struct kvm_pmu_events pmu_events; > > }; > > > > +#define KVM_HOST_PSCI_0_1_CPU_SUSPEND BIT(0) > > +#define KVM_HOST_PSCI_0_1_CPU_ON BIT(1) > > +#define KVM_HOST_PSCI_0_1_CPU_OFF BIT(2) > > +#define KVM_HOST_PSCI_0_1_MIGRATE BIT(3) > > + > > +struct kvm_host_psci_config { > > + /* PSCI version used by host. */ > > + u32 version; > > + > > + /* Function IDs used by host if version is v0.1. */ > > + struct psci_0_1_function_ids function_ids_0_1; > > + > > + /* Bitmask of functions enabled for v0.1, bits KVM_HOST_PSCI_0_1_*. */ > > + unsigned int enabled_functions_0_1; > > Nit: the conventional type for bitmaps is 'unsigned long'. > Also, "enabled" seems odd. Isn't it actually "available"? Sure, that or "implemented" works here. Since there are only 4 functions here, it might make sense to use independent bools rather than a bitmap, which might make this a bit simpler... > > get_psci_0_1_function_ids(); > > + kvm_host_psci_config.version = psci_ops.get_version(); > > + > > + if (kvm_host_psci_config.version == PSCI_VERSION(0, 1)) { > > + kvm_host_psci_config.function_ids_0_1 = get_psci_0_1_function_ids(); > > + kvm_host_psci_config.enabled_functions_0_1 = > > + (psci_ops.cpu_suspend ? KVM_HOST_PSCI_0_1_CPU_SUSPEND : 0) | > > + (psci_ops.cpu_off ? KVM_HOST_PSCI_0_1_CPU_OFF : 0) | > > + (psci_ops.cpu_on ? KVM_HOST_PSCI_0_1_CPU_ON : 0) | > > + (psci_ops.migrate ? KVM_HOST_PSCI_0_1_MIGRATE : 0); ... since e.g. this could be roughly: kvm_host_psci_config.cpu_suspend_implemented = psci_ops.cpu_suspend; kvm_host_psci_config.cpu_off_implemented = psci_ops.cpu_off; kvm_host_psci_config.cpu_on_implemented = psci_ops.cpu_on; kvm_host_psci_config.migrate_implemented = psci_ops.migrate; > > +static inline bool is_psci_0_1_cpu_suspend(u64 func_id) > > +{ > > + return is_psci_0_1_function_enabled(KVM_HOST_PSCI_0_1_CPU_SUSPEND) && > > + (func_id == kvm_host_psci_config.function_ids_0_1.cpu_suspend); > > +} ...and similarly: return kvm_host_psci_config.cpu_suspend_implemented && func_id == kvm_host_psci_config.function_ids_0_1.cpu_suspend) > Otherwise looks OK. Don't bother respinning the series for my > comments, I can tidy things up as I apply it if there are no other > issues. FWIW, I'm happy with whatever choose to do here, so don't feel like you have to follow my suggestions above. Thanks, Mark. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C344C4361B for ; Tue, 8 Dec 2020 17:27:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC789207D8 for ; Tue, 8 Dec 2020 17:27:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC789207D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cxZOv4yIIFVy9Fwg3p2CEK9ZGECUukD0flqW18PcxME=; b=QeDxl0bdiWvpN5WjnnacyA/yM iyWRU3YVUbntI1lF59lLp3zTDa2UorDtARUv8LorFqNifsqiqfJuKrh9C363WHRbkEh64yElSTh6n LnMYM+mVQmQNWkvJO/MOKINNCws7nTovrdLjqonkIF4aIvz1/ZQLuMyQL5MeiMtUFGZcNEZDd1N43 WvavgSp/XbgvgmDpiPYdfg45eBR44AOSPXylcSdZnDTroCG3XhJ2Gu6WX1/yCCcIwR4PDYo0PYtqQ BMpUokSW+SaVQBlZD7+sX205lkq3kXW9rfQ4GxQHihHKJtomoMN64AmO1F4f2x+r0j62+B1u9WIwZ u8beH6faA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmgl3-0004G5-U7; Tue, 08 Dec 2020 17:26:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmgl1-0004Fe-PY for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2020 17:26:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 982841FB; Tue, 8 Dec 2020 09:26:31 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.29.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DCD4F3F68F; Tue, 8 Dec 2020 09:26:29 -0800 (PST) Date: Tue, 8 Dec 2020 17:26:28 +0000 From: Mark Rutland To: Marc Zyngier Subject: Re: [PATCH 1/6] kvm: arm64: Prevent use of invalid PSCI v0.1 function IDs Message-ID: <20201208172628.GB18222@C02TD0UTHF1T.local> References: <20201208142452.87237-1-dbrazdil@google.com> <20201208142452.87237-2-dbrazdil@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201208_122635_944132_E3D72D6C X-CRM114-Status: GOOD ( 28.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Suzuki K Poulose , Catalin Marinas , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, David Brazdil , Will Deacon , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Dec 08, 2020 at 03:56:39PM +0000, Marc Zyngier wrote: > On 2020-12-08 14:24, David Brazdil wrote: > > PSCI driver exposes a struct containing the PSCI v0.1 function IDs > > configured in the DT. However, the struct does not convey the > > information whether these were set from DT or contain the default value > > zero. This could be a problem for PSCI proxy in KVM protected mode. > > > > Extend config passed to KVM with a bit mask with individual bits set > > depending on whether the corresponding function pointer in psci_ops is > > set, eg. set bit for PSCI_CPU_SUSPEND if psci_ops.cpu_suspend != NULL. > > > > Previously config was split into multiple global variables. Put > > everything into a single struct for convenience. > > > > Reported-by: Mark Rutland > > Signed-off-by: David Brazdil > > --- > > arch/arm64/include/asm/kvm_host.h | 20 +++++++++++ > > arch/arm64/kvm/arm.c | 14 +++++--- > > arch/arm64/kvm/hyp/nvhe/psci-relay.c | 53 +++++++++++++++++++++------- > > 3 files changed, 70 insertions(+), 17 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h > > b/arch/arm64/include/asm/kvm_host.h > > index 11beda85ee7e..828d50d40dc2 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -240,6 +241,25 @@ struct kvm_host_data { > > struct kvm_pmu_events pmu_events; > > }; > > > > +#define KVM_HOST_PSCI_0_1_CPU_SUSPEND BIT(0) > > +#define KVM_HOST_PSCI_0_1_CPU_ON BIT(1) > > +#define KVM_HOST_PSCI_0_1_CPU_OFF BIT(2) > > +#define KVM_HOST_PSCI_0_1_MIGRATE BIT(3) > > + > > +struct kvm_host_psci_config { > > + /* PSCI version used by host. */ > > + u32 version; > > + > > + /* Function IDs used by host if version is v0.1. */ > > + struct psci_0_1_function_ids function_ids_0_1; > > + > > + /* Bitmask of functions enabled for v0.1, bits KVM_HOST_PSCI_0_1_*. */ > > + unsigned int enabled_functions_0_1; > > Nit: the conventional type for bitmaps is 'unsigned long'. > Also, "enabled" seems odd. Isn't it actually "available"? Sure, that or "implemented" works here. Since there are only 4 functions here, it might make sense to use independent bools rather than a bitmap, which might make this a bit simpler... > > get_psci_0_1_function_ids(); > > + kvm_host_psci_config.version = psci_ops.get_version(); > > + > > + if (kvm_host_psci_config.version == PSCI_VERSION(0, 1)) { > > + kvm_host_psci_config.function_ids_0_1 = get_psci_0_1_function_ids(); > > + kvm_host_psci_config.enabled_functions_0_1 = > > + (psci_ops.cpu_suspend ? KVM_HOST_PSCI_0_1_CPU_SUSPEND : 0) | > > + (psci_ops.cpu_off ? KVM_HOST_PSCI_0_1_CPU_OFF : 0) | > > + (psci_ops.cpu_on ? KVM_HOST_PSCI_0_1_CPU_ON : 0) | > > + (psci_ops.migrate ? KVM_HOST_PSCI_0_1_MIGRATE : 0); ... since e.g. this could be roughly: kvm_host_psci_config.cpu_suspend_implemented = psci_ops.cpu_suspend; kvm_host_psci_config.cpu_off_implemented = psci_ops.cpu_off; kvm_host_psci_config.cpu_on_implemented = psci_ops.cpu_on; kvm_host_psci_config.migrate_implemented = psci_ops.migrate; > > +static inline bool is_psci_0_1_cpu_suspend(u64 func_id) > > +{ > > + return is_psci_0_1_function_enabled(KVM_HOST_PSCI_0_1_CPU_SUSPEND) && > > + (func_id == kvm_host_psci_config.function_ids_0_1.cpu_suspend); > > +} ...and similarly: return kvm_host_psci_config.cpu_suspend_implemented && func_id == kvm_host_psci_config.function_ids_0_1.cpu_suspend) > Otherwise looks OK. Don't bother respinning the series for my > comments, I can tidy things up as I apply it if there are no other > issues. FWIW, I'm happy with whatever choose to do here, so don't feel like you have to follow my suggestions above. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel