Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp354939pxb; Wed, 11 Nov 2020 05:32:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJycKyb8sFRvR2yxYAKFqJHzqbvCIU8pvWBS1cW2XjvyRDrzSaCk8tapSy7bM+wj5SBQ5Tr9 X-Received: by 2002:a05:6402:206:: with SMTP id t6mr4877293edv.291.1605101544864; Wed, 11 Nov 2020 05:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605101544; cv=none; d=google.com; s=arc-20160816; b=qzogeaeBF+m03KMAbMpOGS2xvOeUaHfhch76MLrq3puHFE5Mh5lfrj3/XQwl6iWU84 njCPR8/YdgWyXK+OFX74kRc403BEQ+aZBP+wKSNKcCBRzuvXbNmL75Vlbolw7FBOAxGB fjug0toMdUzT3CkAwIObf0Ws52SLU5Jm1O4m4imQdeBzph2tJ40/1AtSLOPwdMzq0cp6 +T48K0OzAdn47gBXJ9adYB3xOnnEcai4vF0PQtPGKt6iR2KsyrTo01xAJrmPCUJaOSgF mByvvqL0nhcB5miCVfVjNhizeUro8gtJKt55IThgsHlopIooiin6fcvDbwLu60/+eLmQ RF2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=iPE1PmTV97jXtpTFv8ml0fRrSLjFSlb3dCJ8xt7Obns=; b=hJiOFNHpc1X6WktTYlCGW+XMUO9LAFAdZqqO8P8PRq7bw5dxPGc0n41Q9+AvrYne4S xVTzgEJkVdTSG1jdIB6xRgyt8T1utWG8iV2R9GUgFTGUzwx3NgmMmAzEAl86T3YPqW0O RsGfe5TRTvnIfkHGxFtlHKl639wm0YGTqALqOB3aluNnMN6Km8C6knH8nYxJzzTallP9 3+fU0FUwToYWKYvndCW0ptJMHOeffVH93sM5x7teU8LclmizqOlnbQPCX/iu50W/1kpg odX5lHez/UEJFh8XnYg1ydxlYkOVmvohN2IwAUM/DM1+61joA/WGx890NrVduXzVzlG0 Nf5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LQOyM7Pk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s17si1263745edt.578.2020.11.11.05.31.55; Wed, 11 Nov 2020 05:32:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LQOyM7Pk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbgKKN3d (ORCPT + 99 others); Wed, 11 Nov 2020 08:29:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:60476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgKKN3c (ORCPT ); Wed, 11 Nov 2020 08:29:32 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 79F7E206CA; Wed, 11 Nov 2020 13:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605101371; bh=ylTTLDgMGhQsPJGM41QX1ib3jMY1oRlkQOFl8wohlls=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LQOyM7PkxvpiYnD3r6xnWlmHvX0F0NhA8zzxDBs0TxhOmTjWZbcTycsjIfAAsvLUx U/Vqm/+0M/PlXBPlSSu31FqiCseSlSMtrm5W/kcxxpGntOMRNIvbXTDrQRiewNgHLb 2b68uft0I0UJKxxucNiks+kjPAjXb6+gvVNwD900= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kcqBl-009lwE-4n; Wed, 11 Nov 2020 13:29:29 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 11 Nov 2020 13:29:29 +0000 From: Marc Zyngier To: David Brazdil Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , Andrew Walbran , kernel-team@android.com Subject: Re: [PATCH v1 07/24] kvm: arm64: Create nVHE copy of cpu_logical_map In-Reply-To: <20201111130321.qalrzfabdonrwvsz@google.com> References: <20201109113233.9012-1-dbrazdil@google.com> <20201109113233.9012-8-dbrazdil@google.com> <20201111130321.qalrzfabdonrwvsz@google.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <15a580e6ac06294ead8859fba8f51deb@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: dbrazdil@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, qperret@google.com, ascull@google.com, qwandor@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-11 13:03, David Brazdil wrote: >> > +/* >> > + * nVHE copy of data structures tracking available CPU cores. >> > + * Only entries for CPUs that were online at KVM init are populated. >> > + * Other CPUs should not be allowed to boot because their features were >> > + * not checked against the finalized system capabilities. >> > + */ >> > +u64 __ro_after_init __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] >> > = INVALID_HWID }; >> >> I'm not sure what __ro_after_init means once we get S2 isolation. > > It is stretching the definition of 'init' a bit, I know, but I don't > see what > your worry is about S2? The intention is to mark this read-only for > .hyp.text > at runtime. With S2, the host won't be able to write to it after KVM > init. > Obviously that's currently not the case. More importantly, EL2 can write to it at any time, which is the bit I'm worried about, as it makes the annotation misleading. > One thing we might change in the future is marking it RW for some > initial > setup in a HVC handler, then marking it RO for the rest of uptime. That'd be a desirable outcome, and it would be consistent with the rest of the kernel. > >> >> > + >> > +u64 cpu_logical_map(int cpu) >> >> nit: is there any reason why "cpu" cannot be unsigned? The thought >> of a negative CPU number makes me shiver... > > Same here. That's how it's defined in kernel proper, so I went with > that. I'm happy to deviate from the kernel (give the function a different name if this clashes with existing include files). We can also fix the rest of the kernel (I've just written the trivial patch). >> >> > +{ >> > + if (cpu < 0 || cpu >= ARRAY_SIZE(__cpu_logical_map)) >> > + hyp_panic(); >> > + >> > + return __cpu_logical_map[cpu]; >> > +} >> > + >> > unsigned long __hyp_per_cpu_offset(unsigned int cpu) >> > { >> > unsigned long *cpu_base_array; >> >> Overall, this patch would make more sense closer it its use case >> (in patch 19). I also don't understand why this lives in percpu.c... > > I didn't think it called for adding another C file for this. How about > we > rename this file to smp.c? Would that make sense for both? Make that hyp-smp.c, please! M. -- Jazz is not dead. It just smells funny...