Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp330995lqr; Wed, 5 Jun 2024 07:23:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyKnq6I/2soshcxwA5zvu1hpkcx7So8x23BNBUvQbzTx3cc/b4uutGJyNaFUYWzvTDXvQFjiIYqNn6B2Dw3mjUx2jY8SbFBhepZQ8NLg== X-Google-Smtp-Source: AGHT+IENi0/NG9ojgU8qWvniFFxWrJXF7akFekutKKf3AZwIAIc16w/YlJEJcRb2WOCwQIKWFx3Q X-Received: by 2002:a50:d019:0:b0:57a:2817:477b with SMTP id 4fb4d7f45d1cf-57a8b6f7a0amr2275424a12.22.1717597430480; Wed, 05 Jun 2024 07:23:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717597430; cv=pass; d=google.com; s=arc-20160816; b=TVPTJKYWP8sPy03GA5vtgwG5Wn0YIZ1nckIdVB7W9k3jmmevw6hSQf2efyBm2s1WGv HpPWZZ3oWaFICJrpT7Z81xLwJIdumchI5939elrOHLiSh8yMBs3ey3mo8soxhL2C5OaW tPg3/OMXK5TzDnEYVJ3um8WiCXnbvo3AZotb1cDkhqbNN8xfIQHqUaV/qDXvrBTEbdPr MGbLrkN4bKKjiN/Pp3rSGJ3r0j0TRs0g4xZnSOOpehY2S1MCokCRiEIInGLcacOOGiWc 70TJMK0GFAQe8ozzo1YMP0STMtl3xboSJFtXKehR/J7wR3W4Ubrba97YHebG0hQN6kAh iLxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=LvVshO+KN4NNrct7o6V84rhHGa2nQ4U5rvJJ0qDRFtI=; fh=VoOO0wdhVThowoWxa3dPCZJPos/o6tw25VQ5HHerco0=; b=aKNtmDLbUGumVp8zcINqj6+VhtF20Dxzq5RFcxK75XvSlQEvoLvf7+ijAnzcP18gWv xs4xKaCR2aMqH6YjdnE05P8SVVV8I7Xcp1DlsrCu81SpNq8B8WnVOJpL6vrWwbvjOXLu YUuhJjS93ts10mUvrLHUaRJV4eakUZKf7DYnIA4q0/+aZwLzj1yFoDupaO5LZv7WddHc T5p4vh5jKB3I2H3dsFbQHUKXzVXztwi8LIAFJmCgaZalacm9dZl7CYL5eaFwLAapvpTd pydXeNW80BVF4No0KfkXGvPPHCIeXhsiA29YhfVYx7YJMlaZUHmE1MbOSOGfEktbLI2z J4Dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vdL2Efv+; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-202770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202770-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a7d878a26si2081089a12.107.2024.06.05.07.23.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 07:23:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vdL2Efv+; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-202770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202770-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 390EE1F230AC for ; Wed, 5 Jun 2024 14:22:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F10D1CAAC; Wed, 5 Jun 2024 14:22:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vdL2Efv+" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4432319D8A3 for ; Wed, 5 Jun 2024 14:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717597367; cv=none; b=fq9oA6Q7qodrpBun8qg41ySaDjJ+tpgW4PNWkjDBJ4/hr/lzSk6EYDHk3ggI1M4bPzGK2aTnQc/89Wt7OEfblXU0HAeOkqeo9jvoZF38Hi30XTec2V9lrhRBWauw0AZ1JZBic7wkkt4xRpFHM538vQPEzgJsNE2QDj8ozZVrleI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717597367; c=relaxed/simple; bh=OaxfX57DdLiPPMZLsvwQEjhvOkJKa+3clCY0xOaO3zo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eXiUpBRTyheVGjHUFOiylyR4DWEEyAJqPHgCSNLA9Sd3XW6MDbAafr3amZwO50qaLy/O+ic0eweC8ItZPMPGYX/xhHjq4xSp/yjm1t6fu8WmZYLrhzSZky3sTBVFGUUHNJ217Ulvz6KqBm11aK6TCsa8f0dkfEpD+3uLmWmNnDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vdL2Efv+; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-62a089511f9so12549017b3.1 for ; Wed, 05 Jun 2024 07:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717597365; x=1718202165; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LvVshO+KN4NNrct7o6V84rhHGa2nQ4U5rvJJ0qDRFtI=; b=vdL2Efv+ZXfVhSj5TrphVGbH8MdNP5SLAXrnFZrPzzSrJlb48cbzsqdyIIfOjnm4If w2uWnp5VV0r3+IFMs32pqVdayQ3CWNs1iofdBtW9ynZYQol/LQbA4XvHlcyG+KxfuQ5W KBmGGtxm6Uc0mirsshQkw7DfaiMxHbrJ6QPgv8JTi63cn1nWS22tkhcLt3rodOKePpRV jfTBseZY1AHPu5RwHU/GH1YrTyC33UpXBrqwFcYwoeiuZnIOqfQ7esW5y46NHkPVu1tN 7OYRmccq8+CFdvVkS/hkDhS9zzmOXkCZ+tGTxfQpGI/WJwKFHXdnNKB0towjGk5vyVeU ipVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717597365; x=1718202165; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LvVshO+KN4NNrct7o6V84rhHGa2nQ4U5rvJJ0qDRFtI=; b=kPFznxXZi74X6RyFA+Zbm5wt5i7eEvUmPAgoO596rbIvNlcxLIqDYltUla+R/BImsc krUZNLpu4la3QeoD0/aEL6tYCK7/gecKNgeG0z2wdXvbGIZ4rQnnVqQeRWuCq1BcmE4n 3FBmWXstIUU0SJdfq9Vt31ND+TqHcEgHmqg/gwiT3meQBXBPNLQ8cihe8F/8C1qT+YqV ynPKTrP0D8o4gZvXuEOiyQg11LUo46d5XoCvxO3MqCuGzYoRMM+h7ECdTt959+a/kx7G as6bd+2OWoi+avNrjKtbb03w9k1Vi8nWEYesR+xe/R32YZd5L5SIDoydjICIZRoMAGq0 04tQ== X-Forwarded-Encrypted: i=1; AJvYcCUJdojm+A1LXbQQ7tkWgZJevXZWauyG17NMdGxVedsdBH01A10l6gzOqjhEn6GrJCiIPAGPIUcC6Sluj5IV+ON5aO+klN7BTbhEs2g7 X-Gm-Message-State: AOJu0YyQdpwHtBSL6PP+KAToHU2Bm/8A6Kkdg1E5krVZR9tCX6W7maJy ZIRg3hFLX+mVBdadHMixXaSHnMHQ6tb65KrQ8KTi71zTm2Sl7z6Ql46Y/pso8h+J/Hq///tn2ES JYQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:d89:b0:61b:32dc:881d with SMTP id 00721157ae682-62cba666c6fmr7877257b3.3.1717597365293; Wed, 05 Jun 2024 07:22:45 -0700 (PDT) Date: Wed, 5 Jun 2024 07:22:43 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH V5 4/4] KVM: selftests: Add test for configure of x86 APIC bus frequency From: Sean Christopherson To: Reinette Chatre Cc: isaku.yamahata@intel.com, pbonzini@redhat.com, erdemaktas@google.com, vkuznets@redhat.com, vannapurve@google.com, jmattson@google.com, mlevitsk@redhat.com, xiaoyao.li@intel.com, chao.gao@intel.com, rick.p.edgecombe@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Tue, Jun 04, 2024, Reinette Chatre wrote: > > > +/* > > > + * Pick one convenient value, 1.5GHz. No special meaning and different from > > > + * the default value, 1GHz. > > > > I have no idea where the 1GHz comes from. KVM doesn't force a default TSC, KVM > > uses the underlying CPU's frequency. Peeking further ahead, I don't understand > > why this test sets KVM_SET_TSC_KHZ. That brings in a whole different set of > > behavior, and that behavior is already verified by tsc_scaling_sync.c. > > > > I suspect/assume this test forces a frequency so that it can hardcode the math, > > but (a) that's odd and (b) x86 selftests really should provide a udelay() so that > > goofy stuff like this doesn't end up in random tests. > > I believe the "default 1GHz" actually refers to the default APIC bus frequency and > the goal was indeed to (a) make the TSC frequency different from APIC bus frequency, > and (b) make math easier. > > Yes, there is no need to use KVM_SET_TSC_KHZ. An implementation of udelay() would > require calibration and to make this simple for KVM I think we can just use > KVM_GET_TSC_KHZ. For now I continue to open code this (see later) since I did not > notice similar patterns in existing tests that may need a utility. I'd be happy > to add a utility if the needed usage pattern is clear since the closest candidate > I could find was xapic_ipi_test.c that does not have a nop loop. Please add a utility. ARM and RISC-V already implement udelay(), and this isn't the first test that's wanted udelay() functionality. At the very least, it'd be nice to have for debug, e.g. to be able to insert artificial delay if a test is failing due to a suspected race suspected. I.e. this is likely an "if you build it, they will come" situations. > > Unless I'm misremembering, the timer still counts when the LVT entry is masked > > so just mask the IRQ in the LVT. Or rather, keep the entry masked in the LVT. > > hmmm ... I do not think this is specific to LVT entry but instead an attempt > to ignore all maskable external interrupt that may interfere with the test. I doubt it. And if that really is the motiviation, that's a fools errand. This is _guest_ code. Disabling IRQs in the guest doesn't prevent host IRQs from being delivered, it only blocks virtual IRQs. And KVM selftests guests should never receive virtual IRQs unless the test itself explicitly sends them. > LVT entry is prevented from triggering because if the large configuration value. Yes and no. A large configuration value _should_ avoid a timer IRQ, but the entire point of this test is to verify KVM correctly emulates the timer. If this test does its job and finds a KVM bug that causes the timer to prematurely expire, then unmasking the LVT entry will generate an unexpected IRQ. Of course, the test doesn't configure a legal vector so the IRQ will never be delivered. We could fix that problem, but then a test failure would manifest as a hard-to-triage unexpected event, compared to an explicit TEST_ASSERT() on the timer value. That said, I'm not totally pposed to letting the guest die if KVM unexpectedly injects a timer IRQ, e.g. if all is well, it's a cheap way to provide a bit of extra coverage. On the other hand, masking the interrupt is even simpler, and the odds of false pass are low.