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=-12.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6DE81C433DB for ; Fri, 5 Feb 2021 20:04:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D99964FBA for ; Fri, 5 Feb 2021 20:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233455AbhBESVg (ORCPT ); Fri, 5 Feb 2021 13:21:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:48914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233066AbhBEPTg (ORCPT ); Fri, 5 Feb 2021 10:19:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4A7564F2C; Fri, 5 Feb 2021 17:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612544413; bh=bYsyypHJHkCDMPq/yGSFgDLzazYUpF+GyWHhaLu3g4k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b1jCslKGu5syM6wrgfzO+JQED3kse4raQl0d6FfhlQitKk+PIqGWsucshvT5xTTDT pFgPhLBLy0lnyOoljOXKrQtVRJRYMQY0OAWwFJk+4+Fp8+fCoMCCz8RiNq/7A8GvwT scyQNLe4GsQOdJx6RRmimhK+Iv6oHqD20IyhZq7qoah7ToC4DQ5H24blnfQCoo6qxA zJ3fFY25tCWmIi2HnxEzY5JqdsQbVmqld1lGesBnu1pP5ENmCt4t4tE0NUWf9f2GbF qS492rMyHch6HYBMm9czMXIuew2DqXpXu5d/HH0b2PJ6rjESiv0gM/XUS4YUwFRLvT 9NXR0ve6CzKgw== Date: Fri, 5 Feb 2021 17:00:06 +0000 From: Will Deacon To: Marc Zyngier Cc: Steven Price , netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, seanjc@google.com, richardcochran@gmail.com, Mark.Rutland@arm.com, suzuki.poulose@arm.com, Andre.Przywara@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, justin.he@arm.com, jianyong.wu@arm.com, kernel-team@android.com Subject: Re: [PATCH v17 1/7] arm/arm64: Probe for the presence of KVM hypervisor Message-ID: <20210205170005.GC22665@willie-the-truck> References: <20210202141204.3134855-1-maz@kernel.org> <20210202141204.3134855-2-maz@kernel.org> <20210205111921.GA22109@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 05, 2021 at 04:50:27PM +0000, Marc Zyngier wrote: > On 2021-02-05 11:19, Will Deacon wrote: > > On Fri, Feb 05, 2021 at 09:11:00AM +0000, Steven Price wrote: > > > On 02/02/2021 14:11, Marc Zyngier wrote: > > > > + for (i = 0; i < 32; ++i) { > > > > + if (res.a0 & (i)) > > > > + set_bit(i + (32 * 0), __kvm_arm_hyp_services); > > > > + if (res.a1 & (i)) > > > > + set_bit(i + (32 * 1), __kvm_arm_hyp_services); > > > > + if (res.a2 & (i)) > > > > + set_bit(i + (32 * 2), __kvm_arm_hyp_services); > > > > + if (res.a3 & (i)) > > > > + set_bit(i + (32 * 3), __kvm_arm_hyp_services); > > > > > > The bit shifts are missing, the tests should be of the form: > > > > > > if (res.a0 & (1 << i)) > > > > > > Or indeed using a BIT() macro. > > > > Maybe even test_bit()? > > Actually, maybe not doing things a-bit-at-a-time is less error prone. > See below what I intend to fold in. > > Thanks, > > M. > > diff --git a/drivers/firmware/smccc/kvm_guest.c > b/drivers/firmware/smccc/kvm_guest.c > index 00bf3c7969fc..08836f2f39ee 100644 > --- a/drivers/firmware/smccc/kvm_guest.c > +++ b/drivers/firmware/smccc/kvm_guest.c > @@ -2,8 +2,8 @@ > > #define pr_fmt(fmt) "smccc: KVM: " fmt > > -#include > #include > +#include > #include > #include > > @@ -13,8 +13,8 @@ static DECLARE_BITMAP(__kvm_arm_hyp_services, > ARM_SMCCC_KVM_NUM_FUNCS) __ro_afte > > void __init kvm_init_hyp_services(void) > { > - int i; > struct arm_smccc_res res; > + u32 val[4]; > > if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_HVC) > return; > @@ -28,16 +28,13 @@ void __init kvm_init_hyp_services(void) > > memset(&res, 0, sizeof(res)); > arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID, &res); > - for (i = 0; i < 32; ++i) { > - if (res.a0 & (i)) > - set_bit(i + (32 * 0), __kvm_arm_hyp_services); > - if (res.a1 & (i)) > - set_bit(i + (32 * 1), __kvm_arm_hyp_services); > - if (res.a2 & (i)) > - set_bit(i + (32 * 2), __kvm_arm_hyp_services); > - if (res.a3 & (i)) > - set_bit(i + (32 * 3), __kvm_arm_hyp_services); > - } > + > + val[0] = lower_32_bits(res.a0); > + val[1] = lower_32_bits(res.a1); > + val[2] = lower_32_bits(res.a2); > + val[3] = lower_32_bits(res.a3); > + > + bitmap_from_arr32(__kvm_arm_hyp_services, val, ARM_SMCCC_KVM_NUM_FUNCS); Nice! That's loads better. Will 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=-10.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 E87BAC433E0 for ; Fri, 5 Feb 2021 17:00:19 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 2F14964F2D for ; Fri, 5 Feb 2021 17:00:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F14964F2D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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 94BFD4B458; Fri, 5 Feb 2021 12:00:18 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org 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 p0-89MBc4p6c; Fri, 5 Feb 2021 12:00:17 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4DB794B44A; Fri, 5 Feb 2021 12:00:17 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D7ABA4B422 for ; Fri, 5 Feb 2021 12:00:15 -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 Rw32i8E694uA for ; Fri, 5 Feb 2021 12:00:14 -0500 (EST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 8F5D14B3BD for ; Fri, 5 Feb 2021 12:00:14 -0500 (EST) Received: by mail.kernel.org (Postfix) with ESMTPSA id D4A7564F2C; Fri, 5 Feb 2021 17:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612544413; bh=bYsyypHJHkCDMPq/yGSFgDLzazYUpF+GyWHhaLu3g4k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b1jCslKGu5syM6wrgfzO+JQED3kse4raQl0d6FfhlQitKk+PIqGWsucshvT5xTTDT pFgPhLBLy0lnyOoljOXKrQtVRJRYMQY0OAWwFJk+4+Fp8+fCoMCCz8RiNq/7A8GvwT scyQNLe4GsQOdJx6RRmimhK+Iv6oHqD20IyhZq7qoah7ToC4DQ5H24blnfQCoo6qxA zJ3fFY25tCWmIi2HnxEzY5JqdsQbVmqld1lGesBnu1pP5ENmCt4t4tE0NUWf9f2GbF qS492rMyHch6HYBMm9czMXIuew2DqXpXu5d/HH0b2PJ6rjESiv0gM/XUS4YUwFRLvT 9NXR0ve6CzKgw== Date: Fri, 5 Feb 2021 17:00:06 +0000 From: Will Deacon To: Marc Zyngier Subject: Re: [PATCH v17 1/7] arm/arm64: Probe for the presence of KVM hypervisor Message-ID: <20210205170005.GC22665@willie-the-truck> References: <20210202141204.3134855-1-maz@kernel.org> <20210202141204.3134855-2-maz@kernel.org> <20210205111921.GA22109@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: justin.he@arm.com, kvm@vger.kernel.org, netdev@vger.kernel.org, richardcochran@gmail.com, seanjc@google.com, linux-kernel@vger.kernel.org, Steven Price , Andre.Przywara@arm.com, john.stultz@linaro.org, yangbo.lu@nxp.com, pbonzini@redhat.com, tglx@linutronix.de, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org 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 Fri, Feb 05, 2021 at 04:50:27PM +0000, Marc Zyngier wrote: > On 2021-02-05 11:19, Will Deacon wrote: > > On Fri, Feb 05, 2021 at 09:11:00AM +0000, Steven Price wrote: > > > On 02/02/2021 14:11, Marc Zyngier wrote: > > > > + for (i = 0; i < 32; ++i) { > > > > + if (res.a0 & (i)) > > > > + set_bit(i + (32 * 0), __kvm_arm_hyp_services); > > > > + if (res.a1 & (i)) > > > > + set_bit(i + (32 * 1), __kvm_arm_hyp_services); > > > > + if (res.a2 & (i)) > > > > + set_bit(i + (32 * 2), __kvm_arm_hyp_services); > > > > + if (res.a3 & (i)) > > > > + set_bit(i + (32 * 3), __kvm_arm_hyp_services); > > > > > > The bit shifts are missing, the tests should be of the form: > > > > > > if (res.a0 & (1 << i)) > > > > > > Or indeed using a BIT() macro. > > > > Maybe even test_bit()? > > Actually, maybe not doing things a-bit-at-a-time is less error prone. > See below what I intend to fold in. > > Thanks, > > M. > > diff --git a/drivers/firmware/smccc/kvm_guest.c > b/drivers/firmware/smccc/kvm_guest.c > index 00bf3c7969fc..08836f2f39ee 100644 > --- a/drivers/firmware/smccc/kvm_guest.c > +++ b/drivers/firmware/smccc/kvm_guest.c > @@ -2,8 +2,8 @@ > > #define pr_fmt(fmt) "smccc: KVM: " fmt > > -#include > #include > +#include > #include > #include > > @@ -13,8 +13,8 @@ static DECLARE_BITMAP(__kvm_arm_hyp_services, > ARM_SMCCC_KVM_NUM_FUNCS) __ro_afte > > void __init kvm_init_hyp_services(void) > { > - int i; > struct arm_smccc_res res; > + u32 val[4]; > > if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_HVC) > return; > @@ -28,16 +28,13 @@ void __init kvm_init_hyp_services(void) > > memset(&res, 0, sizeof(res)); > arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID, &res); > - for (i = 0; i < 32; ++i) { > - if (res.a0 & (i)) > - set_bit(i + (32 * 0), __kvm_arm_hyp_services); > - if (res.a1 & (i)) > - set_bit(i + (32 * 1), __kvm_arm_hyp_services); > - if (res.a2 & (i)) > - set_bit(i + (32 * 2), __kvm_arm_hyp_services); > - if (res.a3 & (i)) > - set_bit(i + (32 * 3), __kvm_arm_hyp_services); > - } > + > + val[0] = lower_32_bits(res.a0); > + val[1] = lower_32_bits(res.a1); > + val[2] = lower_32_bits(res.a2); > + val[3] = lower_32_bits(res.a3); > + > + bitmap_from_arr32(__kvm_arm_hyp_services, val, ARM_SMCCC_KVM_NUM_FUNCS); Nice! That's loads better. Will _______________________________________________ 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=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 ED706C433E6 for ; Fri, 5 Feb 2021 17:01:36 +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 434E564ECA for ; Fri, 5 Feb 2021 17:01:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 434E564ECA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=nCjWvsgCmlFtdCzUmpgYNBmYOD1DiJzQatbOIar7+hg=; b=wJuDYmvUbMFGBhEVq7tcNlBNw 2x7rcjfIuPRTaYVcYtZy/WFv1ZJiC92IWkfJsqOIK1OeFOoA2PttWqxUeBhXcrZJtBg1fAFE/018s EzY+6Wv31HhLpDrUb6SfMT9y9zHiI7sx6/okCDbRv6du9uxcz3jJhoY5js6VtVasYi8UlUjtaeMxM 4g8hu5HEnsw7EqCmXK7uDeZqa57UzGhjWhNjBpJZSaZRUUed8/Ii24LH6KuKKamw5rRYMEwIPSOwa cVJ2sjdkjU3yJg78mb0sTSvTlEmamOXrT4Qi5YxS4+QJ6ZOsilDv9fUcyUbuhgQQL8qISNMtbLZcM 7kcqrJZ1A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l84T0-0001Yx-2o; Fri, 05 Feb 2021 17:00:22 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l84Ss-0001WZ-KV for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 17:00:15 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4A7564F2C; Fri, 5 Feb 2021 17:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612544413; bh=bYsyypHJHkCDMPq/yGSFgDLzazYUpF+GyWHhaLu3g4k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b1jCslKGu5syM6wrgfzO+JQED3kse4raQl0d6FfhlQitKk+PIqGWsucshvT5xTTDT pFgPhLBLy0lnyOoljOXKrQtVRJRYMQY0OAWwFJk+4+Fp8+fCoMCCz8RiNq/7A8GvwT scyQNLe4GsQOdJx6RRmimhK+Iv6oHqD20IyhZq7qoah7ToC4DQ5H24blnfQCoo6qxA zJ3fFY25tCWmIi2HnxEzY5JqdsQbVmqld1lGesBnu1pP5ENmCt4t4tE0NUWf9f2GbF qS492rMyHch6HYBMm9czMXIuew2DqXpXu5d/HH0b2PJ6rjESiv0gM/XUS4YUwFRLvT 9NXR0ve6CzKgw== Date: Fri, 5 Feb 2021 17:00:06 +0000 From: Will Deacon To: Marc Zyngier Subject: Re: [PATCH v17 1/7] arm/arm64: Probe for the presence of KVM hypervisor Message-ID: <20210205170005.GC22665@willie-the-truck> References: <20210202141204.3134855-1-maz@kernel.org> <20210202141204.3134855-2-maz@kernel.org> <20210205111921.GA22109@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210205_120014_871377_00B2287A X-CRM114-Status: GOOD ( 16.91 ) 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: Mark.Rutland@arm.com, jianyong.wu@arm.com, justin.he@arm.com, kvm@vger.kernel.org, suzuki.poulose@arm.com, netdev@vger.kernel.org, richardcochran@gmail.com, seanjc@google.com, linux-kernel@vger.kernel.org, Steven Price , Andre.Przywara@arm.com, john.stultz@linaro.org, yangbo.lu@nxp.com, pbonzini@redhat.com, tglx@linutronix.de, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Steve.Capper@arm.com 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 Fri, Feb 05, 2021 at 04:50:27PM +0000, Marc Zyngier wrote: > On 2021-02-05 11:19, Will Deacon wrote: > > On Fri, Feb 05, 2021 at 09:11:00AM +0000, Steven Price wrote: > > > On 02/02/2021 14:11, Marc Zyngier wrote: > > > > + for (i = 0; i < 32; ++i) { > > > > + if (res.a0 & (i)) > > > > + set_bit(i + (32 * 0), __kvm_arm_hyp_services); > > > > + if (res.a1 & (i)) > > > > + set_bit(i + (32 * 1), __kvm_arm_hyp_services); > > > > + if (res.a2 & (i)) > > > > + set_bit(i + (32 * 2), __kvm_arm_hyp_services); > > > > + if (res.a3 & (i)) > > > > + set_bit(i + (32 * 3), __kvm_arm_hyp_services); > > > > > > The bit shifts are missing, the tests should be of the form: > > > > > > if (res.a0 & (1 << i)) > > > > > > Or indeed using a BIT() macro. > > > > Maybe even test_bit()? > > Actually, maybe not doing things a-bit-at-a-time is less error prone. > See below what I intend to fold in. > > Thanks, > > M. > > diff --git a/drivers/firmware/smccc/kvm_guest.c > b/drivers/firmware/smccc/kvm_guest.c > index 00bf3c7969fc..08836f2f39ee 100644 > --- a/drivers/firmware/smccc/kvm_guest.c > +++ b/drivers/firmware/smccc/kvm_guest.c > @@ -2,8 +2,8 @@ > > #define pr_fmt(fmt) "smccc: KVM: " fmt > > -#include > #include > +#include > #include > #include > > @@ -13,8 +13,8 @@ static DECLARE_BITMAP(__kvm_arm_hyp_services, > ARM_SMCCC_KVM_NUM_FUNCS) __ro_afte > > void __init kvm_init_hyp_services(void) > { > - int i; > struct arm_smccc_res res; > + u32 val[4]; > > if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_HVC) > return; > @@ -28,16 +28,13 @@ void __init kvm_init_hyp_services(void) > > memset(&res, 0, sizeof(res)); > arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID, &res); > - for (i = 0; i < 32; ++i) { > - if (res.a0 & (i)) > - set_bit(i + (32 * 0), __kvm_arm_hyp_services); > - if (res.a1 & (i)) > - set_bit(i + (32 * 1), __kvm_arm_hyp_services); > - if (res.a2 & (i)) > - set_bit(i + (32 * 2), __kvm_arm_hyp_services); > - if (res.a3 & (i)) > - set_bit(i + (32 * 3), __kvm_arm_hyp_services); > - } > + > + val[0] = lower_32_bits(res.a0); > + val[1] = lower_32_bits(res.a1); > + val[2] = lower_32_bits(res.a2); > + val[3] = lower_32_bits(res.a3); > + > + bitmap_from_arr32(__kvm_arm_hyp_services, val, ARM_SMCCC_KVM_NUM_FUNCS); Nice! That's loads better. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel