Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 419FCC433F5 for ; Tue, 30 Nov 2021 00:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235118AbhK3BAe (ORCPT ); Mon, 29 Nov 2021 20:00:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbhK3BAd (ORCPT ); Mon, 29 Nov 2021 20:00:33 -0500 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32836C061574 for ; Mon, 29 Nov 2021 16:57:15 -0800 (PST) Received: by mail-yb1-xb35.google.com with SMTP id g17so47397661ybe.13 for ; Mon, 29 Nov 2021 16:57:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=esRLWzH6dw+Ce7phJ2ONogztplO8dpDdVUer7uLYFyE=; b=U5aJzHs/FlOo0fNLHNpFTCG7aV5AVGzHjOwJv+ZRQZ2UYblO/Xoq68Mh+LgMAMEAwG gwa4zJ90Q4Vp3p//JZbIjVpEVxN22f3h+4+7sxeGO3sWwSmqmkrdz9jnHCSb8YiN2upS D5/Ndr10UjtHbiuh4FI5cWeoCkqsB0aTL44awIBISsM9N3zTXpwRLBVNjjFjIWCBIAR2 CqaFqQtCrMACvIkUHE15giu+ir9UH3UZ8bOr0YqtuXy0pXWMKyxt97pf5dNW50HQAd3P Xq4aMkwtelVEamSaY/KLEzVzDqoYGw++6mQuJua5WoTXkJxRUXI/ALyHcOXeHdQOkQOB T1FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=esRLWzH6dw+Ce7phJ2ONogztplO8dpDdVUer7uLYFyE=; b=zbqatO+VQoaJjZRSlUCEXmtiAmAM76h/WFFDyT4kAFi0c6t4KQWPawlUU5Di/67tBq kEmz52b4vk8oKt8F2ow+uNxoBNEGltUg9/hwPRnKjTKhczN1aylaQwrpJfk1PhL9E9j8 8y4RYYGTaY9j+vYFGq0OddJX7Y7go9JBPP0OOGvw1OohU27+7R2SrPihmXzWgq3Hvpiv rY2blhpms0Eu4uXvHOoHxm4I7l8Abux1dSghDYeH6TwtQfXQmY1L4SI8jspFZmy09IMt qn4epVqxL46EW0krHPNghDE6lp9FGEbF2tAE2zklybmI3gyoDy8OiKTHkAXWHhmh0v8M 6Duw== X-Gm-Message-State: AOAM530OtMLln6QRVoFSlo/FL7AmmnsilwE4TyF11HRTY41Gom4k9PS5 YZO+qWO7RBF2fTSH3GAfwYok/PvqZmIr8vI9ZTtMmg== X-Google-Smtp-Source: ABdhPJxBtrnBwZDK0SfMN9ZP26BpdgE0OykhJRvFEkCn6qO1fburjBb59wkMhZpu1UbE5WIus+YADqwKUV0GYHNYlNY= X-Received: by 2002:a25:d003:: with SMTP id h3mr33831953ybg.184.1638233834133; Mon, 29 Nov 2021 16:57:14 -0800 (PST) MIME-Version: 1.0 References: <20211113012234.1443009-1-rananta@google.com> <20211113012234.1443009-2-rananta@google.com> <20211127131628.iihianybqbeyjdbg@gator.home> In-Reply-To: <20211127131628.iihianybqbeyjdbg@gator.home> From: Raghavendra Rao Ananta Date: Mon, 29 Nov 2021 16:57:03 -0800 Message-ID: Subject: Re: [RFC PATCH v2 01/11] KVM: arm64: Factor out firmware register handling from psci.c To: Andrew Jones Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 27, 2021 at 5:16 AM Andrew Jones wrote: > > On Sat, Nov 13, 2021 at 01:22:24AM +0000, Raghavendra Rao Ananta wrote: > > Common hypercall firmware register handing is currently employed > > by psci.c. Since the upcoming patches add more of these registers, > > it's better to move the generic handling to hypercall.c for a > > cleaner presentation. > > > > While we are at it, collect all the firmware registers under > > fw_reg_ids[] to help implement kvm_arm_get_fw_num_regs() and > > kvm_arm_copy_fw_reg_indices() in a generic way. > > > > No functional change intended. > > > > Signed-off-by: Raghavendra Rao Ananta > > --- > > arch/arm64/kvm/guest.c | 2 +- > > arch/arm64/kvm/hypercalls.c | 170 +++++++++++++++++++++++++++++++++++ > > arch/arm64/kvm/psci.c | 166 ---------------------------------- > > include/kvm/arm_hypercalls.h | 7 ++ > > include/kvm/arm_psci.h | 7 -- > > 5 files changed, 178 insertions(+), 174 deletions(-) > > > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > > index 5ce26bedf23c..625f97f7b304 100644 > > --- a/arch/arm64/kvm/guest.c > > +++ b/arch/arm64/kvm/guest.c > > @@ -18,7 +18,7 @@ > > #include > > #include > > #include > > -#include > > +#include > > #include > > #include > > #include > > diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c > > index 30da78f72b3b..9e136d91b470 100644 > > --- a/arch/arm64/kvm/hypercalls.c > > +++ b/arch/arm64/kvm/hypercalls.c > > @@ -146,3 +146,173 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) > > smccc_set_retval(vcpu, val[0], val[1], val[2], val[3]); > > return 1; > > } > > + > > +static const u64 fw_reg_ids[] = { > > + KVM_REG_ARM_PSCI_VERSION, > > + KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1, > > + KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2, > > +}; > > + > > +int kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu) > > +{ > > + return ARRAY_SIZE(fw_reg_ids); > > +} > > + > > +int kvm_arm_copy_fw_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices) > > +{ > > + int i; > > + > > + for (i = 0; i < ARRAY_SIZE(fw_reg_ids); i++) { > > + if (put_user(fw_reg_ids[i], uindices)) > > This is missing the ++ on uindices, so it just writes the same offset > three times. > Thanks for catching this! I believe I realized this later and corrected it in patch-04/11 of the series and missed it here. I'll fix it here as well. > > + return -EFAULT; > > + } > > + > > + return 0; > > +} > > I assume the rest of the patch is just a cut+paste move of code. > That's right. Regards, Raghavendra > Thanks, > drew >