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=-8.6 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 CF633C433E6 for ; Wed, 13 Jan 2021 14:23:14 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 1B501233FB for ; Wed, 13 Jan 2021 14:23:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B501233FB Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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 6E23E4B1C7; Wed, 13 Jan 2021 09:23:13 -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=@google.com 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 FoSlo9Eu6Yc3; Wed, 13 Jan 2021 09:23:12 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5A65E4B1B4; Wed, 13 Jan 2021 09:23:12 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 60A604B169 for ; Wed, 13 Jan 2021 09:23:11 -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 H4W5NhsYpoCd for ; Wed, 13 Jan 2021 09:23:10 -0500 (EST) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 493624B0CF for ; Wed, 13 Jan 2021 09:23:10 -0500 (EST) Received: by mail-wm1-f41.google.com with SMTP id 3so1770156wmg.4 for ; Wed, 13 Jan 2021 06:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ilU2a0/z2icSlVjikMlVFb2BH/BMW95h/+2IlgK09tA=; b=mb6J8KGfPGz18jwtpgubLMkATb8/Rkvwe7SvvMpjP59phRqNVcLtJhjhzs6OXZjb6o EtLISbBA9zn1CuHoxX08fV9CbHbHyVIYuzR1+qWBbquftXlJkGGcsZoc9ooIxnKxZb6O AtcwIwSsZ/OL/jjPQLdmBbO869kuB+hFoVPEeqYTn8AM6A7Z70iojhRX6bB6rT/iqk6m KRXaZMpxZO8S7ddTasPh+LF9H+C31ikwzVAuPMBXFZxltyQCk+j41+VrZ73h6K9v3jVK XjJjKhlVvoPBD2z05uCwrAIveAcWR1miyJcm2jFf/chrmST7NPzdHnXr9lJ+YtF9UhQI o5jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ilU2a0/z2icSlVjikMlVFb2BH/BMW95h/+2IlgK09tA=; b=eAVUaHFKFsoQCzuSSATDYmAaw1IvUOI0MIJwLbT1ucjg8GJixxTBQapb2qypbjlaSy mno+OeC6ItV77I9/EExN/TAaKOJwB87/jW/fNlB++KXXHJ1WOf8NPhZKZ8mKHHWwD8YS FO0yaV+ZciehyVgFtKvjfSmwGiA0qdOlCewI0XtxATr1rD/cwTKaqw4CGhMlVe9oAjLu m+caiXS1j35lU3t7t6/vW+AgTTCReNRRnPpbh5ym5amHPZ7j3k9ax091l3JLKPVO5ngv LrOJmKLTimu8VmpNdTH+dTumG8tBsggpIu2gZCZJ6IJRfY7KkCurMLQ7piL0SZ0PkIEk 9LqA== X-Gm-Message-State: AOAM530oxuVmCK84vfKVwOcnS5/wlpywZNlI5sXAeqFrrkd/qLbaY7hC IuRYrVMvBD8Q+/qzxcJLIETSXQ== X-Google-Smtp-Source: ABdhPJwYEfPsoLZ1uDpkgIvVI6ossxrBaWbG9yG2QlOmRPbJjc1rM9tB77wRTJPoRpB2XSFVf/bkkA== X-Received: by 2002:a1c:bc41:: with SMTP id m62mr2484423wmf.46.1610547789081; Wed, 13 Jan 2021 06:23:09 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id a62sm2936823wmf.7.2021.01.13.06.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 06:23:08 -0800 (PST) Date: Wed, 13 Jan 2021 14:23:03 +0000 From: Quentin Perret To: Marc Zyngier Subject: Re: [RFC PATCH v2 13/26] KVM: arm64: Enable access to sanitized CPU features at EL2 Message-ID: References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-14-qperret@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: devicetree@vger.kernel.org, kernel-team@android.com, Frank Rowand , android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , 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 Hey Marc, On Wednesday 13 Jan 2021 at 11:33:13 (+0000), Marc Zyngier wrote: > > +#undef KVM_HYP_CPU_FTR_REG > > +#define KVM_HYP_CPU_FTR_REG(id, name) \ > > + { .sys_id = id, .dst = (struct arm64_ftr_reg *)&kvm_nvhe_sym(name) }, > > +static const struct __ftr_reg_copy_entry { > > + u32 sys_id; > > + struct arm64_ftr_reg *dst; > > Why do we need the whole data structure? Can't we just live with sys_val? I don't have a use-case for anything else than sys_val, so yes I think I should be able to simplify. I'll try that for v3. > > > +} hyp_ftr_regs[] = { > > + #include > > +}; > > Can't this be made __initdata? Good point, that would be nice indeed. Can I use that from outside an __init function? If not, I'll need to rework the code a bit more, but that should be simple enough either way. > > + > > +static int copy_cpu_ftr_regs(void) > > +{ > > + int i, ret; > > + > > + for (i = 0; i < ARRAY_SIZE(hyp_ftr_regs); i++) { > > + ret = copy_ftr_reg(hyp_ftr_regs[i].sys_id, hyp_ftr_regs[i].dst); > > + if (ret) > > + return ret; > > + } > > + > > + return 0; > > +} > > + > > /** > > * Inits Hyp-mode on all online CPUs > > */ > > @@ -1705,6 +1729,13 @@ static int init_hyp_mode(void) > > int cpu; > > int err = 0; > > > > + /* > > + * Copy the required CPU feature register in their EL2 counterpart > > + */ > > + err = copy_cpu_ftr_regs(); > > + if (err) > > + return err; > > + > > Just to keep things together, please move any sysreg manipulation into > sys_regs.c, most probably into kvm_sys_reg_table_init(). Will do. Thanks, Quentin _______________________________________________ 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=-9.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 00651C433E0 for ; Wed, 13 Jan 2021 14:25:32 +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 6804E233FD for ; Wed, 13 Jan 2021 14:25:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6804E233FD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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=27RnNt3m1/xM7ebRV4gPw17mn4FLnHYYssQ+24JSd4M=; b=LXz4Bf6XEQfEEJnRhWqxROOx6 U8oqhHJtzQL/zTaLMS9cLTOb0qSWy7ASSe/jdmWj5ZOTsEHIDBMbaLNt+6UPIYr2LuTh863pjq6fR GxL8iiNxy7sAH6b3S5xO+L7J0Ny3J6a5as3LT5RMEUfuV/VhnDm8pz84AcTepFwZXlXyhNvDUDZ5E 3Q3ilkV3kk4qT+odh4N/1pjo/LRQUvVwQwvBEEU/HsRU5NiPCAXbU/QzIny+8PgM8/pF93MxdYYFw HhgQGNKwp72tp6R9jXSumIKB5En1yCWuB/6zVXFdkGrEwv554UkxWKc9KpMXzglPU3rfzuonhDRJI UT9PT5QGg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzh3T-0007iP-Jl; Wed, 13 Jan 2021 14:23:23 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzh3N-0007bu-Ex for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2021 14:23:22 +0000 Received: by mail-wm1-x329.google.com with SMTP id y23so1772533wmi.1 for ; Wed, 13 Jan 2021 06:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ilU2a0/z2icSlVjikMlVFb2BH/BMW95h/+2IlgK09tA=; b=mb6J8KGfPGz18jwtpgubLMkATb8/Rkvwe7SvvMpjP59phRqNVcLtJhjhzs6OXZjb6o EtLISbBA9zn1CuHoxX08fV9CbHbHyVIYuzR1+qWBbquftXlJkGGcsZoc9ooIxnKxZb6O AtcwIwSsZ/OL/jjPQLdmBbO869kuB+hFoVPEeqYTn8AM6A7Z70iojhRX6bB6rT/iqk6m KRXaZMpxZO8S7ddTasPh+LF9H+C31ikwzVAuPMBXFZxltyQCk+j41+VrZ73h6K9v3jVK XjJjKhlVvoPBD2z05uCwrAIveAcWR1miyJcm2jFf/chrmST7NPzdHnXr9lJ+YtF9UhQI o5jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ilU2a0/z2icSlVjikMlVFb2BH/BMW95h/+2IlgK09tA=; b=r7Rue3Wu6ailqnJxUWKUy5S68oFPfog8ostfaXsNLJh3BA9mXO/S4NuiZqyurivYDs J2NQXF1JQN07pjBeZMQn8RUsZWZzzYeCVkSOJdiztCIUE2p6Si32lSXTI1fXwzGO+jnv 4dhfsfvNTOZjb6YpGlU2kaAEktoHsDqGIhX9tknhyPp5hFB4ri/9bweyDJpOvvAHblNi Z1Zc32IKBrCzJWHxZaB+uzEYXXFKDa81ugMGgtGPIvcn5HNfUoYlLX9Ct+HSax6tdUa7 A5rG/bZZwapKlM68AJ7iLhZX6+f9/fNEXxyIO3AK/ueOgMg/CQZQFCjmQVHfmJ5FXS7n HXAQ== X-Gm-Message-State: AOAM531XVVbLZSt9IxqK5hqCPIE4fIFqZLvAh5yi7tedWIAXK9y2YVet xzrTx81Kxw81pK+RpdLKd1M5zw== X-Google-Smtp-Source: ABdhPJwYEfPsoLZ1uDpkgIvVI6ossxrBaWbG9yG2QlOmRPbJjc1rM9tB77wRTJPoRpB2XSFVf/bkkA== X-Received: by 2002:a1c:bc41:: with SMTP id m62mr2484423wmf.46.1610547789081; Wed, 13 Jan 2021 06:23:09 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id a62sm2936823wmf.7.2021.01.13.06.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 06:23:08 -0800 (PST) Date: Wed, 13 Jan 2021 14:23:03 +0000 From: Quentin Perret To: Marc Zyngier Subject: Re: [RFC PATCH v2 13/26] KVM: arm64: Enable access to sanitized CPU features at EL2 Message-ID: References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-14-qperret@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-20210113_092317_552745_85AC47E0 X-CRM114-Status: GOOD ( 22.01 ) 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 , devicetree@vger.kernel.org, kernel-team@android.com, Frank Rowand , Suzuki K Poulose , android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , 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 Hey Marc, On Wednesday 13 Jan 2021 at 11:33:13 (+0000), Marc Zyngier wrote: > > +#undef KVM_HYP_CPU_FTR_REG > > +#define KVM_HYP_CPU_FTR_REG(id, name) \ > > + { .sys_id = id, .dst = (struct arm64_ftr_reg *)&kvm_nvhe_sym(name) }, > > +static const struct __ftr_reg_copy_entry { > > + u32 sys_id; > > + struct arm64_ftr_reg *dst; > > Why do we need the whole data structure? Can't we just live with sys_val? I don't have a use-case for anything else than sys_val, so yes I think I should be able to simplify. I'll try that for v3. > > > +} hyp_ftr_regs[] = { > > + #include > > +}; > > Can't this be made __initdata? Good point, that would be nice indeed. Can I use that from outside an __init function? If not, I'll need to rework the code a bit more, but that should be simple enough either way. > > + > > +static int copy_cpu_ftr_regs(void) > > +{ > > + int i, ret; > > + > > + for (i = 0; i < ARRAY_SIZE(hyp_ftr_regs); i++) { > > + ret = copy_ftr_reg(hyp_ftr_regs[i].sys_id, hyp_ftr_regs[i].dst); > > + if (ret) > > + return ret; > > + } > > + > > + return 0; > > +} > > + > > /** > > * Inits Hyp-mode on all online CPUs > > */ > > @@ -1705,6 +1729,13 @@ static int init_hyp_mode(void) > > int cpu; > > int err = 0; > > > > + /* > > + * Copy the required CPU feature register in their EL2 counterpart > > + */ > > + err = copy_cpu_ftr_regs(); > > + if (err) > > + return err; > > + > > Just to keep things together, please move any sysreg manipulation into > sys_regs.c, most probably into kvm_sys_reg_table_init(). Will do. Thanks, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 80797C433DB for ; Wed, 13 Jan 2021 14:23:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37BAE233FB for ; Wed, 13 Jan 2021 14:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726238AbhAMOXv (ORCPT ); Wed, 13 Jan 2021 09:23:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbhAMOXv (ORCPT ); Wed, 13 Jan 2021 09:23:51 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E6CBC061786 for ; Wed, 13 Jan 2021 06:23:10 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id y187so1769981wmd.3 for ; Wed, 13 Jan 2021 06:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ilU2a0/z2icSlVjikMlVFb2BH/BMW95h/+2IlgK09tA=; b=mb6J8KGfPGz18jwtpgubLMkATb8/Rkvwe7SvvMpjP59phRqNVcLtJhjhzs6OXZjb6o EtLISbBA9zn1CuHoxX08fV9CbHbHyVIYuzR1+qWBbquftXlJkGGcsZoc9ooIxnKxZb6O AtcwIwSsZ/OL/jjPQLdmBbO869kuB+hFoVPEeqYTn8AM6A7Z70iojhRX6bB6rT/iqk6m KRXaZMpxZO8S7ddTasPh+LF9H+C31ikwzVAuPMBXFZxltyQCk+j41+VrZ73h6K9v3jVK XjJjKhlVvoPBD2z05uCwrAIveAcWR1miyJcm2jFf/chrmST7NPzdHnXr9lJ+YtF9UhQI o5jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ilU2a0/z2icSlVjikMlVFb2BH/BMW95h/+2IlgK09tA=; b=q0INHu4C05TIVZPalxV3M8alJpTYrklix07omzSZtK28xDJ/q0PXDK0kKxQxuBaSnX 5NfA4Sv2NtK05k2DrUgY5WkaP3N8zSB5wsrxPfNKjQ25TpAU4svD6mTJv5eUBfRXZfnv JJT7WV/a//cbK9ziA2o1dfZGMUD8anzxUqlKki+pIBLboUOKNsIcju2MGhVahzSZTi+f w8MeaPOsE6MdnFicMdxaswfQYRHGMNXUbNQ8n1PdAXhdqPzR47zS7SMXN2bUTLe5AShr HcEWLGUH6b16bt1GPXU0lOAeFusQO2py51lweZRhT/bYjGZAK+S/vlTDxVRbb+7NHoxO srsg== X-Gm-Message-State: AOAM531sKaiOk7+cmTXHdU4HgjuyBsfurJmmzphuBEcSGmodAVbdmBHF YXUlVOEeN6tkYc1tlKZiOFNVhQ== X-Google-Smtp-Source: ABdhPJwYEfPsoLZ1uDpkgIvVI6ossxrBaWbG9yG2QlOmRPbJjc1rM9tB77wRTJPoRpB2XSFVf/bkkA== X-Received: by 2002:a1c:bc41:: with SMTP id m62mr2484423wmf.46.1610547789081; Wed, 13 Jan 2021 06:23:09 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id a62sm2936823wmf.7.2021.01.13.06.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 06:23:08 -0800 (PST) Date: Wed, 13 Jan 2021 14:23:03 +0000 From: Quentin Perret To: Marc Zyngier Cc: Catalin Marinas , Will Deacon , James Morse , Julien Thierry , Suzuki K Poulose , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Fuad Tabba , Mark Rutland , David Brazdil Subject: Re: [RFC PATCH v2 13/26] KVM: arm64: Enable access to sanitized CPU features at EL2 Message-ID: References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-14-qperret@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: devicetree@vger.kernel.org Hey Marc, On Wednesday 13 Jan 2021 at 11:33:13 (+0000), Marc Zyngier wrote: > > +#undef KVM_HYP_CPU_FTR_REG > > +#define KVM_HYP_CPU_FTR_REG(id, name) \ > > + { .sys_id = id, .dst = (struct arm64_ftr_reg *)&kvm_nvhe_sym(name) }, > > +static const struct __ftr_reg_copy_entry { > > + u32 sys_id; > > + struct arm64_ftr_reg *dst; > > Why do we need the whole data structure? Can't we just live with sys_val? I don't have a use-case for anything else than sys_val, so yes I think I should be able to simplify. I'll try that for v3. > > > +} hyp_ftr_regs[] = { > > + #include > > +}; > > Can't this be made __initdata? Good point, that would be nice indeed. Can I use that from outside an __init function? If not, I'll need to rework the code a bit more, but that should be simple enough either way. > > + > > +static int copy_cpu_ftr_regs(void) > > +{ > > + int i, ret; > > + > > + for (i = 0; i < ARRAY_SIZE(hyp_ftr_regs); i++) { > > + ret = copy_ftr_reg(hyp_ftr_regs[i].sys_id, hyp_ftr_regs[i].dst); > > + if (ret) > > + return ret; > > + } > > + > > + return 0; > > +} > > + > > /** > > * Inits Hyp-mode on all online CPUs > > */ > > @@ -1705,6 +1729,13 @@ static int init_hyp_mode(void) > > int cpu; > > int err = 0; > > > > + /* > > + * Copy the required CPU feature register in their EL2 counterpart > > + */ > > + err = copy_cpu_ftr_regs(); > > + if (err) > > + return err; > > + > > Just to keep things together, please move any sysreg manipulation into > sys_regs.c, most probably into kvm_sys_reg_table_init(). Will do. Thanks, Quentin