Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp912070ybs; Mon, 25 May 2020 02:19:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8AuW7AV05txt7XCvoYl00W5Km/ukJzSa0wHZSzYtZ71lcwun1+Rd7kTnRliQ/sP19IjHM X-Received: by 2002:a05:6402:19ae:: with SMTP id o14mr14075727edz.235.1590398392994; Mon, 25 May 2020 02:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590398392; cv=none; d=google.com; s=arc-20160816; b=ZId2WOnBU00EZu9YtOSI+kLBOktH6DX3zNqwicx8tsXxxkAF1BC2RBN409erPwbQ+r sCoPLQMvLPoz6STGr7Pa5WjU+F8aPOpbg6DqGFPE8myZDIKHGYOZanQzKbiePEMtfDQU VPeg6fJAYDYu4RiEZs0P7Cqdiqj0b4JK0+LwQr8hSmhEtjji8hC6fbSPVlMttzPNHX+J dqWlj1Lqa3pYx/dvcKa5OGa7xJBAynvEENbGAFuONm1nPf8hIRoD2BI/Kdy3FczytaBE g8U9+5fZ0Yya0MNmwtUX0Zr7ixnsrqOe2F5HMc+Zz5bcI4735xiZvagv56DiYK1JjVoS YGxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=sV2ND4njW67/fs5WpFAMLzqXXhRMCeQeasdwpcDaenM=; b=aIKt8fVnl51tmd3oQhrKIRKNyJU66m56DDA+1USjgxDvKv25F/qoJBoymlfM0MkL87 kwAJECgSmRdMvaZQ1aE+8Wq8xx5GpV3GNENjxriVxkK33obYQDwzJS8LErufAVSYd9te OeNBH/USQLJVBt3G/GoPna7c/wbySnZjK4CYrEghB31qkTPFoUQ57CEv+EQuuA1OnmT/ HDMjmbIXpPm0RkSAQKgGtOe5H0p4I0Ie9OKTAI+NJHbLo6hNd0nuQa/Sj0Rv9qoOG4qL atDHJlgv0G4jyIw1Hya7/4s+OLL+RwXPlc4+o8HSjj9COY1J+CEWMU6vNCbk5H+SnQnr domw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tXnRIYph; 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 g32si10252202edd.124.2020.05.25.02.19.30; Mon, 25 May 2020 02:19:52 -0700 (PDT) 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=tXnRIYph; 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 S2389476AbgEYJRW (ORCPT + 99 others); Mon, 25 May 2020 05:17:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:38290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389454AbgEYJRV (ORCPT ); Mon, 25 May 2020 05:17:21 -0400 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 01ED020787; Mon, 25 May 2020 09:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590398241; bh=dvoIblhrB6r6q1w4YgHnKBzB3u8MDjy2EHOsa4SWZok=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tXnRIYphXASv22/CWUBMA4CPRNsDbUMhgCnKjxTTC6dq9DDNazs1+GztuGsokQpEJ 72QM5aF0JoA15SMnoO0AX6SPOL6GCj0SXNeERYxlYPaPRT7hQ4f+IaxJUF+lIYihOX pyq7Ce4X2AFg/w1e44/Sm5YB7VXDDhAc7W7i/lfo= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jd9EU-00F730-Ux; Mon, 25 May 2020 10:17:19 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 25 May 2020 10:17:18 +0100 From: Marc Zyngier To: Richard Cochran , Jianyong Wu Cc: netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, Mark.Rutland@arm.com, will@kernel.org, suzuki.poulose@arm.com, steven.price@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, Kaly.Xin@arm.com, justin.he@arm.com, Wei.Chen@arm.com, nd@arm.com Subject: Re: [RFC PATCH v12 10/11] arm64: add mechanism to let user choose which counter to return In-Reply-To: <20200524021106.GC335@localhost> References: <20200522083724.38182-1-jianyong.wu@arm.com> <20200522083724.38182-11-jianyong.wu@arm.com> <20200524021106.GC335@localhost> User-Agent: Roundcube Webmail/1.4.4 Message-ID: <306951e4945b9e486dc98818ba24466d@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: richardcochran@gmail.com, jianyong.wu@arm.com, netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, Mark.Rutland@arm.com, will@kernel.org, suzuki.poulose@arm.com, steven.price@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, Kaly.Xin@arm.com, justin.he@arm.com, Wei.Chen@arm.com, nd@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-24 03:11, Richard Cochran wrote: > On Fri, May 22, 2020 at 04:37:23PM +0800, Jianyong Wu wrote: >> In general, vm inside will use virtual counter compered with host use >> phyical counter. But in some special scenarios, like nested >> virtualization, phyical counter maybe used by vm. A interface added in >> ptp_kvm driver to offer a mechanism to let user choose which counter >> should be return from host. > > Sounds like you have two time sources, one for normal guest, and one > for nested. Why not simply offer the correct one to user space > automatically? If that cannot be done, then just offer two PHC > devices with descriptive names. There is no such thing as a distinction between nested or non-nested. Both counters are available to the guest at all times, and said guest can choose whichever it wants to use. So the hypervisor (KVM) has to support both counters as a reference. For a Linux guest, we always know which reference we're using (the virtual counter). So it is pointless to expose the choice to userspace at all. > >> diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c >> index fef72f29f3c8..8b0a7b328bcd 100644 >> --- a/drivers/ptp/ptp_chardev.c >> +++ b/drivers/ptp/ptp_chardev.c >> @@ -123,6 +123,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned >> int cmd, unsigned long arg) >> struct timespec64 ts; >> int enable, err = 0; >> >> +#ifdef CONFIG_ARM64 >> + static long flag; > > static? This is not going to fly. > >> + * In most cases, we just need virtual counter from host and >> + * there is limited scenario using this to get physical counter >> + * in guest. >> + * Be careful to use this as there is no way to set it back >> + * unless you reinstall the module. > > How on earth is the user supposed to know this? > > From your description, this "flag" really should be a module > parameter. Not even that. If anything, the driver can obtain full knowledge of which counter is in use without any help. And the hard truth is that it is *always* the virtual counter as far as Linux is concerned. M. -- Jazz is not dead. It just smells funny...