Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp100757imu; Tue, 22 Jan 2019 14:41:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ly+yInFb6iqu0smC/WUr6gFBjx2rzwLGL3mcaRtMW3lwcURP8AFzpMcqpuQhewHLpdHgf X-Received: by 2002:a17:902:e18d:: with SMTP id cd13mr36157740plb.262.1548196917401; Tue, 22 Jan 2019 14:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548196917; cv=none; d=google.com; s=arc-20160816; b=E5n5cF7SiE/MCVGMVyTeHVtWyW6XCp9JknVSE5pA6hp2KwcedIfHvQLl/QBhuHhYsA 0b57KoHKnvXBPHXHRgOTdGJpPTn2D3ngUHgDeQPbRpGCTF+eJ5DPF771IA+3GqgqTTpl 8bd33WntY0NFYYmlqO26KH56XQyVSDiOv4JvHdZhqQmC0+EIm/0E9dfKyvN34xAAymgj AqXG1WtG9Gw1GGEy5Sqc9CAIUrPIocKxyKSB7Xg+hwsguGWIwSpdFQ/pB4N83+gn033P F465dECaXLH1BAurjuOAiNARzDG9o9TY5KIEzktCBFcQiRipnRXmP1ibboIC0E1glQgM S+4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:mime-version:date:in-reply-to :subject:cc:to:from:user-agent:references; bh=FJ83eOPiHN5U3oHYM3Z5TLavdBsAnewxxNOkrj9Qz2Q=; b=X9B8jns8fGT4PUcQDxKASMyeyqi+EauIor7vnzhXy1VSgl9TP7g7XByHU5kun2df4G ISVJeVPzAESdE3pl0epLeRs5IJVlImFGFnMSXZuz5Nw+xCeZx4/u8+4SWqG4mWIJNhvw WmfP1XkMQwPuJnnUSjfBwD1HC6GjYQtWh/Hqixow+C5X2wEWPDhVOTuxm7VYTgbiCwyR EjlEUL6N3w1xSF6Zz8odvfz79DBj8bY8xSBbLL0Z7iPcae8mMV42Q9zAFXyBTydifvko XzdWV/0ZEFhqnu0cQ07jEftm6NlpBab+p5wXrgBDzxuN4XPQG4GQz+ObitcF/9PhlYBh yavw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y27si16171180pga.459.2019.01.22.14.41.21; Tue, 22 Jan 2019 14:41:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727175AbfAVWjE (ORCPT + 99 others); Tue, 22 Jan 2019 17:39:04 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46328 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726218AbfAVWjD (ORCPT ); Tue, 22 Jan 2019 17:39:03 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0MMXuK7114780 for ; Tue, 22 Jan 2019 17:39:02 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2q6942f18g-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jan 2019 17:39:01 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 Jan 2019 22:39:00 -0000 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 22 Jan 2019 22:38:56 -0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0MMctM216974054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 22 Jan 2019 22:38:56 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E42D67807A; Tue, 22 Jan 2019 22:38:55 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA1B978069; Tue, 22 Jan 2019 22:38:51 +0000 (GMT) Received: from morokweng.localdomain (unknown [9.85.185.73]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS; Tue, 22 Jan 2019 22:38:51 +0000 (GMT) References: <20190122211758.8317-1-bauerman@linux.ibm.com> User-agent: mu4e 1.0; emacs 26.1 From: Thiago Jung Bauermann To: "Lendacky\, Thomas" Cc: "x86\@kernel.org" , "kvm\@vger.kernel.org" , "iommu\@lists.linux-foundation.org" , "linux-kernel\@vger.kernel.org" , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Ram Pai Subject: Re: [PATCH 1/2] dma-direct: set_memory_{en,de}crypted() take number of pages In-reply-to: Date: Tue, 22 Jan 2019 20:38:46 -0200 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 19012222-0004-0000-0000-000014D6AD71 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010458; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000275; SDB=6.01150328; UDB=6.00599461; IPR=6.00930660; MB=3.00025245; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-22 22:39:00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012222-0005-0000-0000-00008A521BC7 Message-Id: <87womwfhc9.fsf@morokweng.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-22_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901220168 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lendacky, Thomas writes: > On 1/22/19 3:17 PM, Thiago Jung Bauermann wrote: >> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c >> index 355d16acee6d..bc78c37220ba 100644 >> --- a/kernel/dma/direct.c >> +++ b/kernel/dma/direct.c >> @@ -166,7 +166,7 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size, >> >> ret = page_address(page); >> if (force_dma_unencrypted()) { >> - set_memory_decrypted((unsigned long)ret, 1 << get_order(size)); >> + set_memory_decrypted((unsigned long)ret, 1); > > The get_order() function will return the order for the specified size. To > then get the number of pages you perform the shift as is being done. The > change is definitely wrong since you are now hardcoding the page count to > 1. The call to __dma_direct_alloc_pages() will allocate more than one page > if the size is greater than a page. You are correct, of course. Sorry for the noise and thanks for explaining. -- Thiago Jung Bauermann IBM Linux Technology Center