Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3086669pxk; Mon, 7 Sep 2020 02:48:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCzBmzu1Zd2U0uDDPAFCZiOum8d7mapBtAzD4focRcZNBw12+VmMfFfpMo/5q1tNi/7m7I X-Received: by 2002:a17:906:3553:: with SMTP id s19mr1934788eja.178.1599472090910; Mon, 07 Sep 2020 02:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599472090; cv=none; d=google.com; s=arc-20160816; b=I36QD51YbOtxSYeHvyw3dWO/EhWCYz+HZC/8X19CI0fSK2/BPZuZOt49f7PkOHZq5z 4irTrYiHjjlWA7kUshBcLnmgyG/kY8SLQds214eBfzlt7186uUbIqOXErvH2ZJh5nI1W VoQNU9wFjOf92QspYTG7BUanpOrKzc5oz3SxsL5g03pX3eZF55b7fHj9kAOQOGLknAtM TddxHrEjB4Ws5HDP65YNIrjzRPBlhFrs15+yf9GLKdiA3rNBu4Gx+l+TG7ew6thw1QhL pwu4ltuzfVOVhfvqaeoQbV8AWDjg3jst/S0CfGIjB0UHfzMe32LDf1J6s6/hjAjzJjmm jC8w== 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=n4AVastbWRMIO9/4TtoKPnWDKZu/wQREu4Z+CVFzIX4=; b=qZ0tkxBrw6jEYUQntERyyfwaZZd0AT3hIIJEPunkwlp8y34P/dCkr/IdTIHGP3CaM6 uOQkQDcGRPjj8Tp8bZDOA46QSR0TrsXtuvPrMdOgExCXKADrOv9YXDrw34UfXKIDuUlQ mpkaeTs0JUSYeMqfRfOE3/1KH9uW/nI8rm1TQVGF0FbHYzgeGh8wXMNDzNNAow8jhhc7 EJoEoXUBdbiafy5gpJe2JCG8iIEprGh0DOKWxiFqrVhQZvEHTMHHgmGA1cLcJC4d5f0N vMk8kqYaM8Je0iiDQvmaJ6/iF8Hp1gxWrSJ/NEOOj/bfzj+d8UQJrlA8U3J0jzMW5JjA pgJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=19AbdD+E; 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 l9si9444370ejc.672.2020.09.07.02.47.47; Mon, 07 Sep 2020 02:48:10 -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=19AbdD+E; 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 S1728404AbgIGJrF (ORCPT + 99 others); Mon, 7 Sep 2020 05:47:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:44148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726301AbgIGJrE (ORCPT ); Mon, 7 Sep 2020 05:47:04 -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 49EFA2078E; Mon, 7 Sep 2020 09:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599472023; bh=cFHskjvmHO3vzxD+eGBoRNZ+sFpiHGFme6jLOuWP8Uc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=19AbdD+EC1bO4XviCsVbOEsgKBlvuTcIcRwYpDXdAbiyDIC2ngljNeSByIj6g2WwR pwHlJAa2zca7ViqS+HXJHlbRqiyn/WpxFytm5SMsvxtaqOBqDi0a5jaudF1eVdGURu jTZbUs3gK3gLc/gZXJVqSV1JOAEE6FHqZ7nCuP54= 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 1kFDjp-009iuT-BE; Mon, 07 Sep 2020 10:47:01 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 07 Sep 2020 10:47:01 +0100 From: Marc Zyngier To: 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, richardcochran@gmail.com, Mark Rutland , will@kernel.org, Suzuki Poulose , Steven Price , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve Capper , Justin He , nd Subject: Re: [PATCH v14 08/10] ptp: arm64: Enable ptp_kvm for arm64 In-Reply-To: References: <20200904092744.167655-1-jianyong.wu@arm.com> <20200904092744.167655-9-jianyong.wu@arm.com> <874kocmqqx.wl-maz@kernel.org> <366387fa507f9c5d5044549cea958ce1@kernel.org> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <67f3381467d02c8d3f25682cd99898e9@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: 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, richardcochran@gmail.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, Justin.He@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-09-07 10:28, Jianyong Wu wrote: >> -----Original Message----- >> From: Marc Zyngier >> Sent: Monday, September 7, 2020 4:55 PM >> To: Jianyong Wu [...] >> >> arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_FEATUR >> >> ES_FUNC_ID, >> >> > + &hvc_res); >> >> > + if (!(hvc_res.a0 | BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) >> >> > + return -EOPNOTSUPP; >> >> > + >> >> > + return 0; >> >> >> >> What happens if the >> >> ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID function isn't >> implemented >> >> (on an old kernel or a non-KVM hypervisor)? The expected behaviour is >> >> that a0 will contain SMCCC_RET_NOT_SUPPORTED, which is -1. >> >> The result is that this function always returns "supported". Not an >> >> acceptable behaviour. >> >> >> > Oh! it's really a stupid mistake, should be "&" not "|". >> >> But even then. (-1 & whatever) is always true. > > Yeah, what about checking if a0 is non-negative first? Like: > if (hvc_res.a0 < 0 || !(hvc_res.a0 & BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP))) > return -EOPNOTSUPP; I don't get it. You already carry a patch from Will that gives you a way to check for a service (kvm_arm_hyp_service_available()). Why do you need to reinvent the wheel? M. -- Jazz is not dead. It just smells funny...