Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1523745rwb; Tue, 27 Sep 2022 14:35:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+dacMPIyXsaLVqs/Gwrvh3RPUuoVNbmui7vfNnliHjKyFCDZEGIhQtS1Q2uBGT5W+RdSM X-Received: by 2002:a17:902:9006:b0:178:b494:c15a with SMTP id a6-20020a170902900600b00178b494c15amr29584919plp.37.1664314535829; Tue, 27 Sep 2022 14:35:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664314535; cv=pass; d=google.com; s=arc-20160816; b=kdFjgmTS8quRRZiqmA2RSoXCBQKfo0QX06VhJBYvzwKv2UJUQiW/wtkC7POm2vtV8U QFXTYGfjWSNqsRvUDOhFlZ/hsxgFqTjeeYhDI0OyBsVWEldTeQ2U4BXxX2jWATfOQHAN qggCGhzqZpl2cSMMKXLN0D9Wjgm5/KLriteg/DnXacORxtBYzxN0hPa8Y7NZeX6NpvqG eAIr8pT6nNp53JyQfhRz3s7+QvikqpawSaGEAjvBCmbY8t/htbCNh8o3rRTyj9YZX2MT wn0jrL8gOKY4LQQQDW7qSY2kWAuvRWfKq3f649zua/uGn6p65QzOeoEqjcHk+PzHJWdM wdxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=/HCrL2EmxLMjSddcWYXAGPW1YYq8nk5LbUo+8uvB8nc=; b=qk2rwiE1qdEHC3GJPjfC+A7AZM6yQsmB1g5n/6EQu67Fu9cI8XkZ5TvZHpfe+BK2XM uLS8KehxeC6MqdLsyNTiTiGDZ7SRWiPgKEQzzF69t11KSj+tpcZimycySy/GYK+sn0Ri S2Zay01nLf9dnAG2keWG5wSDk5myyUjyJ+iLgI2zbcUth2NCqi0JttNpN0Reg1WtRSlR gibqRfpY8vb7ZpBGE9Sr6JL6Rpl2sfeYHTS4K+ubp24PiHuOsP+ZYJBvpxIMMpn4s3M3 ZcQNxaAPnsm3HNJs7qy2gbvQ03Rp7zAg3YWguc8PfNNudkqohwkZ/gZPv34Rgih4JFpN aUUQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=elUaPJyg; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a63d649000000b00439fbc1b5afsi3307955pgj.412.2022.09.27.14.35.23; Tue, 27 Sep 2022 14:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=elUaPJyg; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232982AbiI0Uq0 (ORCPT + 99 others); Tue, 27 Sep 2022 16:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiI0Up7 (ORCPT ); Tue, 27 Sep 2022 16:45:59 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060.outbound.protection.outlook.com [40.107.243.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 582AB107DFA for ; Tue, 27 Sep 2022 13:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SbU9O1vL7byOsAjsfSYb5Td86DTB7yelhMYjCOXCr1ZQ0gZFetJXS5M46rVf5Oowy6p/iqXPOX0VnSekduQh/sRE6zFSprYdb8i0C735kFGsEAEcgsT7kXgPGraEH+vuyV95oX1rO/UUsxVzHf/5lx5WJ6FaiaCFA1ZWpK8REh6hEdDYCcaQ1GGeBkswLxa9P0jxFlHrlG8mAhYgpmwEWl9eoL/XQwtlRfor1gyyplkcVDcRFvfagF3j/yRRg8yi1YDqoTDcw0u65aocqCLyClxKQeg7CCSm6yVutV0J4m8KNGzotgQtMEDribmQvoGTAaptIkVD77zTPeuBtii3Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/HCrL2EmxLMjSddcWYXAGPW1YYq8nk5LbUo+8uvB8nc=; b=Arp6gW8TzMeYD6jHB+ApD41AeuqAXLObB5UDmXY4RuxIraLEtJJreyOhXkhdKdQqSjwBQbHwCxbjuGxfBtaEcuY6tnltJPE9pubGsLaLbixlujN8cHawHadRrcatzk2+3EkC2hpC3WxMIvLn1L3EW0aLrtyRrPlEelTXKgh2WAeA6AgcIAXa6NbyOztWlM+NrzGwyeEV+IFC0fF55QGoThDhzTxo5Ghqr0xRa1qDidrR6PKPZRiPuVkkGD7B36nE68J1fVDMziD6XxdBxdzMBykbUgYcykcl9fQgdgZnBVB7oxMmyc5J+Fy/870x+eGDm4ixncoGgmNH26HVINZ8VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/HCrL2EmxLMjSddcWYXAGPW1YYq8nk5LbUo+8uvB8nc=; b=elUaPJygSwfWR0OTa5tqjGozY6iTfbl4o0iqjvbO2JXQzgC89KJmBf4a+IpKkQyqBt5PTUF8Zd/HMfG5xk/+LDLOCPzxHaLpkE27N+pCAnd+HayGQ6DZfODifTCfkU5RKzNYxaLKgialyEsB6vbd8FTBXbiu4rseiAo0NAkHSHU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by MW5PR12MB5599.namprd12.prod.outlook.com (2603:10b6:303:194::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Tue, 27 Sep 2022 20:45:53 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::c175:4c:c0d:1396]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::c175:4c:c0d:1396%5]) with mapi id 15.20.5654.026; Tue, 27 Sep 2022 20:45:53 +0000 Message-ID: <30026d7b-a736-5660-2e5e-7e9fcef10101@amd.com> Date: Tue, 27 Sep 2022 15:45:49 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v5 1/6] x86/sev: Fix calculation of end address based on number of pages Content-Language: en-US To: Dave Hansen , linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "Kirill A. Shutemov" , "H. Peter Anvin" , Michael Roth , Joerg Roedel , Andy Lutomirski , Peter Zijlstra References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <51eeb843-204f-5b9d-9f7f-9bf3c22d2c00@intel.com> From: Tom Lendacky In-Reply-To: <51eeb843-204f-5b9d-9f7f-9bf3c22d2c00@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH0P220CA0012.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::18) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5229:EE_|MW5PR12MB5599:EE_ X-MS-Office365-Filtering-Correlation-Id: 7aaa0be6-9aa8-460f-32c5-08daa0c9447b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nQGVUrn3Sq6n8DQJz34BUR424KmyL3zn/8c5htw8Xl+IluuazqW3fQ9YfRcj1rxcIZG8UIhqfC2tVrRFrpvYfSSGL532rwK5DzwV4XcfK8Q9Bu796XU8cUdQbOmyl99KAeHK87TEZyFoY9EXeZN/4dI5EC3Ao9W5j85PktHJ/grkF9cUE0GGGhNJzkjX28eUWnJ3J6emxn4paBpiWP0jgvNHECMhLmMuBKedWoNsm3t1gUkuruzCHKoanNS+ZxyVnuaIcTk7O8IaAv5PAdPM/+CCikWHKab37Q+9WAedX70O1s8lHZ9o2ACp7cYv3vEThdl6B5POQwt9BatrzVW3FdUgWm7Z4+/IbMctLDqtUEW4uItyZ7ZXqDLIYumS/ZkIfneWcqgmT98CHVZ08ZqsZ0UgCwkCLioiq13PIkrDXtgHnUWvkz9gcBqIQLIYsYGFnLy48L8nz067RJLmrPqrQAmCC23YXcGq6VCeB478pVdEE9TFe4Vgxo5TDPpYg2f1MIur57NJ2WwAh/jKuBQXupsxH7rdyvdH7XL/zjzbzDBWKGTJMKGnRqTqiLqFpri2R8BA7HMuz4aQ8wC6fLsIVpSsYpXm/zq35G+usbsOcFgIIUZXvTbV/BE9wWA72jpfNSA8oRXhvFzAfx8q5TOsFM4fXV88bVtgAoY4RUUhT4w7MQ/YXLUsmUsfujz76AK/PI05dHnV09vu9e3ixK4L/ldWbKULEzln3IOIh+uzNZbyg05G4iRJjppBeMRFooPiz6kR/G6lDBayhCXCWf6Y7plHDTWDViTqXGtcY790OoM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(366004)(451199015)(83380400001)(31686004)(86362001)(38100700002)(31696002)(66476007)(36756003)(66556008)(2906002)(4744005)(6512007)(8936002)(7416002)(66946007)(5660300002)(4326008)(8676002)(6506007)(316002)(2616005)(26005)(41300700001)(54906003)(53546011)(186003)(6486002)(478600001)(6666004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZlZ0TkI1Sy92aC9aRUlqZ2FEN3Y4c0xsKzdsQzIzZVNJOEwvVUR5T2VxakVm?= =?utf-8?B?NFZjQ2J1aUFUa0o1UXVXaUxMRVlQd2VKSytvUEx4MlArSklVbERoTTI2SElP?= =?utf-8?B?RjZ6MFZzK2hJalNrajF4dU96QzMwNEpsMzRwRG9oT3l3WUpwRE5DU1V1RHlV?= =?utf-8?B?enFaLzlNNmJJcVRQTldHdENPRmpxdzdwYkJaVDRCQXhIMHlzeFVDRzZDdnRG?= =?utf-8?B?REZLTUhUcGk3ZVRMaVdVSWZQNjBobmE1OG15QzVhVGhTUzFTT09BNytab3Vs?= =?utf-8?B?ZVQxZmhZdFQ1NGNQNkZvRnB0UXA5MkEzTnVUcDZRUGwwMXYxbjZ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u6+ZKHQG/3xYDwANc?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7aaa0be6-9aa8-460f-32c5-08daa0c9447b X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 20:45:53.2869 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OYjedV9URQf4r1AzlwFZdooZ6KYlCDs4hNv83yxBO0+OUET2lbPMfNpAO/CSpCh9AIHZ2o0/AUmgfYW8WNOC9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5599 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/27/22 12:10, Dave Hansen wrote: > On 9/27/22 10:04, Tom Lendacky wrote: >> --- a/arch/x86/kernel/sev.c >> +++ b/arch/x86/kernel/sev.c >> @@ -649,7 +649,7 @@ static void pvalidate_pages(unsigned long vaddr, unsigned int npages, bool valid >> int rc; >> >> vaddr = vaddr & PAGE_MASK; >> - vaddr_end = vaddr + (npages << PAGE_SHIFT); >> + vaddr_end = vaddr + ((unsigned long)npages << PAGE_SHIFT); > > Could we please just fix the fragile typing that cascaded down to this > point? > > Shouldn't 'npages' in this interface be a long? I'll take a look at that. Thanks, Tom > >> struct x86_guest { >> void (*enc_status_change_prepare)(unsigned long vaddr, int npages, bool enc); >> bool (*enc_status_change_finish)(unsigned long vaddr, int npages, bool enc); >> bool (*enc_tlb_flush_required)(bool enc); >> bool (*enc_cache_flush_required)(void); >> };