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=-5.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 C9230C64E7B for ; Tue, 1 Dec 2020 13:53:12 +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 4C64C20705 for ; Tue, 1 Dec 2020 13:53:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="B3uOBq1d"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="nkgSXV2g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C64C20705 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=eQdw/4p7UzEqWbfRDWopfZy05TuV4uN4y5Bl9i/VLI8=; b=B3uOBq1duqdG/LDQ3pHm9TMQg m3nxMRZjc5aar7+cCXviNE2B3N0qkNugOpGDv/rGW6SFM7FOlZBQT/s/3AneLNDelGVknG+tQeu6K 7DBYRSCEJhkfItygxeNy/HM/iUmk5gFSkoFguF7gXu6vOcWwYDhFdj1iLXymU5BARkd0gnr9PvQg4 LMlRSQhmzzcEarWs73VmgBCVBXmhgDklfMaaI6b0i1YuzGdnNOJMYcs0c/dAVnqWWAaE6CaUhZISj q/4l2vGN2QZgYK2Cng9vtTK/XcejnpN6LJmDwJlH2qLXUn0JQunej7t0NUXmDX5Wl9joz/Cwqg/Mu Knrj7025A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kk64L-0001m6-OV; Tue, 01 Dec 2020 13:51:49 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kk64B-0001ku-Dd for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2020 13:51:47 +0000 Received: by mail-wr1-x442.google.com with SMTP id o1so2723029wrx.7 for ; Tue, 01 Dec 2020 05:51:39 -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=EQOI8T+d8gKQ2/dOWJZGivhsk/dAAdxIvvx15lVtny0=; b=nkgSXV2gOuBncMrl6+3qDmAAJ4sR0cdviEFX9turKav6mGUBpXp81f6hKbuJBj5J21 N/LPrBTLq6YzT24g9KYZcIeH/otFXDRLF1bVxLD4QdMx05wn81nclYKmV/Ymr/0lvCGc qE+YeW2TSkoqBDMFyBUyHpLNUen/MGvUi3BE1URoNJGKnWdJZgZXgwuckoFZJuXo6fzv JxgI7Vipe6a5Q85l7yBv3yg/BIFoAcL1Hhp8J6e86aq7ne5qvATCGBPtB2vx5Ih0JSgX ipwQCUb2RNzz9+9u/prs0HS3hKdSabdM+0Oeclxlq/B+fzMfZqHdETKz8L/h71aKuvk2 QUdQ== 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=EQOI8T+d8gKQ2/dOWJZGivhsk/dAAdxIvvx15lVtny0=; b=Sq/VodzK3fiqfIABFv5XFLl9CZkCGzLOmiJpiJrRFnQ3ryaJV3y6dc9GGeX37AzBRy BVqXnDL1QLaN7Vk3uqov9aH1D9D0nxO7RbJ9rxUK3AGOC8QjsOWXFdzugFIDSzF5cJry D9TfavtX5lslw56ktkBVue0hpm9OsaNoSDZRi2laae5Vq2aWeaLGoCC39RyW5jUdFUvM +RLBeJJujMGCWmMPxVFqxnXB+6y5WkoJds70aT2arimnkkpgDGYas8zAGkM5VojyJBHf lTK1XYIk6y6gyDqFP0sUZ/BBCxoDb2PL4jIHXQWYw5fYZ9I8Dy/pJgp0DoW1sFfydKGW X0Qw== X-Gm-Message-State: AOAM532QLX+GLSvWOVvggN8J1UmBRx5Mo4rp4GNwJxAs7X3poDqM/kzN 3ifHOpiAO2UIzvWvnYWPWp2zLw== X-Google-Smtp-Source: ABdhPJwh0+cFKMPciz4Nv7GTSBxYfP4MSIi6pO0Seh9bXRp5bIKM0x+xRWrLyjLNPXBk204l11OtTA== X-Received: by 2002:adf:a39e:: with SMTP id l30mr3882676wrb.195.1606830698299; Tue, 01 Dec 2020 05:51:38 -0800 (PST) Received: from google.com ([2a01:4b00:8523:2d03:7c5f:5ab5:ac1f:89ce]) by smtp.gmail.com with ESMTPSA id e3sm3281251wro.90.2020.12.01.05.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 05:51:37 -0800 (PST) Date: Tue, 1 Dec 2020 13:51:35 +0000 From: David Brazdil To: Sudeep Holla Subject: Re: [PATCH v3 19/23] kvm: arm64: Intercept host's CPU_ON SMCs Message-ID: <20201201135135.ejgqytcxqyiwyic6@google.com> References: <20201126155421.14901-1-dbrazdil@google.com> <20201126155421.14901-20-dbrazdil@google.com> <20201127174726.4b6azdyzn5j6qmao@bogus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201127174726.4b6azdyzn5j6qmao@bogus> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201201_085139_500879_762F53BA X-CRM114-Status: GOOD ( 19.46 ) 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 , Lorenzo Pieralisi , kernel-team@android.com, Jonathan Corbet , Catalin Marinas , Suzuki K Poulose , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Tejun Heo , Dennis Zhou , Christoph Lameter , 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 Sudeep, > > +static unsigned int find_cpu_id(u64 mpidr) > > +{ > > + unsigned int i; > > + > > + /* Reject invalid MPIDRs */ > > + if (mpidr & ~MPIDR_HWID_BITMASK) > > + return INVALID_CPU_ID; > > + > > + for (i = 0; i < NR_CPUS; i++) { > > I may not have understood the flow correctly, so just asking: > This is just called for secondaries on boot right ? No, secondaries are booted before KVM is initialized. kvm_arch_init() installs the hypervisor on each core that is online at that point. That flow does not touch this code. But the kernel can later power down some of those cares and then this handler is called if it tries to power them on again. You can exercise this with: # echo 0 > /sys/devices/system/cpu/cpu5/online # echo 1 > /sys/devices/system/cpu/cpu5/online > And the cpumasks are setup by then ? Cpumasks are initialized before KVM init, so yes, we could copy that information up to EL2 and use it here. That comes down to copying `nr_cpu_ids` because the possible set is logical IDs 0..nr_cpu_ids-1 (see smp_init_cpus()). > Just trying to see if we can use cpu_possible_mask instead of running through > all 256/1k/4k cpus(ofcourse based on NR_CPUS config) I decided to keep things simple because a valid MPIDR should not need to scan the entire array, at most the first `nr_cpu_ids` entries. An invalid MPIDR will scan all NR_CPUS entries but that does not seem worth optimizing for. David _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel