From patchwork Mon Oct 9 09:20:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Stecklina X-Patchwork-Id: 13413183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D51C8E95A96 for ; Mon, 9 Oct 2023 09:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345708AbjJIJWE (ORCPT ); Mon, 9 Oct 2023 05:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345692AbjJIJWD (ORCPT ); Mon, 9 Oct 2023 05:22:03 -0400 Received: from DEU01-BE0-obe.outbound.protection.outlook.com (mail-be0deu01on2080.outbound.protection.outlook.com [40.107.127.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1AF6A2; Mon, 9 Oct 2023 02:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WY3dW2XYEST8sOIiz9X2EhwIpiaMac1eIOb3UihA9bkXj0lilCQZPMvUtJ511pyCSTILV1YL9aWsj9fbnfRnaSr31RGU2f7Sr+wO2rx92gunSr3/3BXj6VHw19mu1sQxM5D3yEN1XqaQPjXnn5XWeY0JWb0v0RCczrnCnB/or9l6YWjfVsJDphWaao9Q6hiVDcCCy8Nk7C+cnXMDrLnaYX4CJKjv6Vo//NbMwU7IrCVIwQyAEVdkr7A0c24ilm3uoAVDzpxu9cV8a0Jq1k3eGO38Iv78HDaCStvT4skqUst7JorhvAAjJ1Bt75MY3bUCM8VxMURDoQ8H65gtyyAJ8Q== 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=xPvahczNfvcmActLmgOBqvbEW/CePOBHq9GcQJYj4ME=; b=RbLOlpOrJoEkdzuIcNwqK/FHdz+/mik9aatplLxQivUxn2VCHzvWGhbpGZHxQv8k5yW7kIyWSKtrLVJPm+gyLiHJjbFRo5zb3tCqMaZdIpZ9WyLARjDIwDbR2+CFDCaKkU9day1uy461Eh31vtE1vD9bx7NTkG4dWnPe4WOjrILPw6KKPzGc0/CQSLPPogT/XJNoKetLqfed0XYuXtY6ttxOB2hrXBNyiDGdbiB/cQfR9+lZho58CixF7Oy/iKyhT427voQLqBtpWk/t3jriqSPIQik/x8pEClVPEbZYABX9jndJkK17HPIOWPczysDlnNyLbXG9d0/8+HskWsO8UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cyberus-technology.de; dmarc=pass action=none header.from=cyberus-technology.de; dkim=pass header.d=cyberus-technology.de; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyberus-technology.de; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xPvahczNfvcmActLmgOBqvbEW/CePOBHq9GcQJYj4ME=; b=kjAR2CQnXPve5ighJZ2Qzti4fV4Uub82qN6zbyMTD1SqWwVNf6gIPn6aFKIpyf365nVA6XDWAUETfC6igv4JBiUkRWq3WYDBuBlZA5BuYYjfcPo80QtRFgmzyPGpFft0FnpIP1hjdDzgZ93mVdKFi9eKolp4OZ5kR2/2mPhv8A2hE2Kp5lLn5cP9ZN+glhI1owa59ZCJCr6ywHEJjNujwJ22N14Jc/0PaXM7USf8QDnWbnWbe/lrvsUM+uvkD68Ylg3seTb3+3EGYsSZ/DQ2Ck8NITz1Uvjzeq/J9pgSA0MJ2/kmiqK0JL3egzT3K5BC1p0myollhdmd7LEjj7+T/A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cyberus-technology.de; Received: from FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:7a::10) by FR0P281MB1983.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Mon, 9 Oct 2023 09:21:58 +0000 Received: from FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM ([fe80::739c:5a5b:9c94:e5ec]) by FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM ([fe80::739c:5a5b:9c94:e5ec%7]) with mapi id 15.20.6863.032; Mon, 9 Oct 2023 09:21:58 +0000 From: Julian Stecklina To: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: Julian Stecklina , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] KVM: x86: Fix partially uninitialized integer in emulate_pop Date: Mon, 9 Oct 2023 11:20:53 +0200 Message-Id: <20231009092054.556935-1-julian.stecklina@cyberus-technology.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231004133827.107-1-julian.stecklina@cyberus-technology.de> References: <20231004133827.107-1-julian.stecklina@cyberus-technology.de> X-ClientProxiedBy: PA7P264CA0404.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:39b::8) To FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:7a::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: FR3P281MB1567:EE_|FR0P281MB1983:EE_ X-MS-Office365-Filtering-Correlation-Id: f6f3688e-01f8-4c6c-176e-08dbc8a92fc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I7RYUAR8FYWag2Lo13Eoa8joZCUER5BawlTcOoZNOigZZs1Oy9v8DiBAB+JBJkHLpkQam9IxRwGX1uvQhl2hycNf3R8Jbn8NNPYDjPbIKmpNtmKoI6irpP62nYD+B8H2G6fz2o0WpAXwsli7yNqzkRpE3+xePIiwBvZBKkRl99YjgUxYmBSGB2uhv95C/GINv8GjL0n58TkEVE1Psx9QUQRas9ltzi1kcvGlY+ddNX022dkqw0O25EpVC/vdbS4K/j8S/IyUekC37tYH+oLTvoz+nBLjE2WDnTwmopleSCVC66zAc/k2wDmM8qet6XmCQeWG1RvDPwsgzaSxXPBhj4upTkNOUWVIUgDGMaa5Tb/P7DnPZjL22C7VXEwykxaUyNfyGBZND3sAzpDjJRS+gO8X5MUTRnVVyYmF3Oegm8rQxy3OOaTKBxiHbJfIPkAy9gjHelgBTcCk8G6c9KW9y1v9cWrjdFxTk5YJbYqqdopqO6EfMkcN2P6xOT11lq0JjP1MpV2QkmYKy3PoS0GrKYHGfev8o7PI8INm8aSkfGACR0LnOVSpw3gADJgh04hx8FvYZeVFOMlDA1zACdnYiP27bUVROAlCy5kRKH+5t+64pT7iazoYFvjhZ2OtDdu/nt2z/sGsnBVqxxXLf5IKCnLooSWsRbebos04pkbptyPse2we4QlbVABMfV1IZR0w X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(39830400003)(376002)(136003)(346002)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(86362001)(38100700002)(36756003)(2906002)(6512007)(478600001)(6486002)(44832011)(5660300002)(41300700001)(8936002)(4326008)(8676002)(6666004)(52116002)(6506007)(83380400001)(2616005)(1076003)(66556008)(66476007)(7416002)(110136005)(316002)(66946007)(26005)(38350700002)(341764005);D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WgfqKbkp2UDG6xqZCd9VpDiIlgiVJ9udRuAVCF+Cdg4swsyhaHzFXp6Ifso7KiOcC2Cu3UYMabFZSkqbWSD8bxNC/ls3aH7YWfaio8q5Bz92EuQYPbBRRYbjP8FT0zsh17k2XPUxuFx5F5LS+nu9nw4nQdtXY9nHcNKzs0zJgKdPIC/fYhaSufoAFAPrK04BqulFd+su5qcipm9eOuRCt63GJjk3fszu9pE6Hf8/bT9aDN2PQKVOXXfUglvLYNkC4DNB9zEaFsnXNv7VlFM3iDGkSZmBzCyiCc0YQ5AxHmTttwfw1svxwiMLljxbjahw+hlauXHCKOGf5kEkjKQ14TeZmXvggk6EypYqP1EWRKf64Zw1t9vZyuyC1z/a1g7BRxzYQIkMDf964TfbPBJcWcCdnJPUGj3LAiU1alqfoQuHfqbtRlwAC00hNuz/TpaIWJGAzsNEvdRocI2yScco/OpBhcEZR1eHIYj4GKnsvF0ERk0qhxow73Y5LT2mbr/Guj7JvCGBEDf1fwqQ2QOEHe2VN72twnm2TY8OH4WNYABleF5zegMoTEEA4FUQbwzje44+gEFWuG0IQZ3/Q34omIOua6o7/WdwJQlvz537+4la1mZr310JboriVI7roc/BqQ= X-OriginatorOrg: cyberus-technology.de X-MS-Exchange-CrossTenant-Network-Message-Id: f6f3688e-01f8-4c6c-176e-08dbc8a92fc2 X-MS-Exchange-CrossTenant-AuthSource: FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 09:21:58.0757 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f4e0f4e0-9d68-4bd6-a95b-0cba36dbac2e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F+xVXPRHQSvemYDgoFRPqMHzgpR0hBwiSiFk3MA+2q32pgHMzyf8tjZx2VOUvHXT+Q/nRxYgvN+K5sWgZY5IX9ku2+13N9xMySDP7QI76v005TdmZenqxt9/MSoePv5S X-MS-Exchange-Transport-CrossTenantHeadersStamped: FR0P281MB1983 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Most code gives a pointer to an uninitialized unsigned long as dest in emulate_pop. len is usually the word width of the guest. If the guest runs in 16-bit or 32-bit modes, len will not cover the whole unsigned long and we end up with uninitialized data in dest. Looking through the callers of this function, the issue seems harmless, but given that none of this is performance critical, there should be no issue with just always initializing the whole value. Even though popa is not reachable in 64-bit mode, I've changed its val variable to unsigned long too to avoid sad copy'n'paste bugs. Signed-off-by: Julian Stecklina --- arch/x86/kvm/emulate.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 2673cd5c46cb..86d0ee9f1a6a 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1862,7 +1862,8 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt, void *dest, int len) { int rc; - unsigned long val, change_mask; + unsigned long val = 0; + unsigned long change_mask; int iopl = (ctxt->eflags & X86_EFLAGS_IOPL) >> X86_EFLAGS_IOPL_BIT; int cpl = ctxt->ops->cpl(ctxt); @@ -1953,7 +1954,7 @@ static int em_push_sreg(struct x86_emulate_ctxt *ctxt) static int em_pop_sreg(struct x86_emulate_ctxt *ctxt) { int seg = ctxt->src2.val; - unsigned long selector; + unsigned long selector = 0; int rc; rc = emulate_pop(ctxt, &selector, 2); @@ -1999,7 +2000,7 @@ static int em_popa(struct x86_emulate_ctxt *ctxt) { int rc = X86EMUL_CONTINUE; int reg = VCPU_REGS_RDI; - u32 val; + unsigned long val = 0; while (reg >= VCPU_REGS_RAX) { if (reg == VCPU_REGS_RSP) { @@ -2228,7 +2229,7 @@ static int em_cmpxchg8b(struct x86_emulate_ctxt *ctxt) static int em_ret(struct x86_emulate_ctxt *ctxt) { int rc; - unsigned long eip; + unsigned long eip = 0; rc = emulate_pop(ctxt, &eip, ctxt->op_bytes); if (rc != X86EMUL_CONTINUE) @@ -2240,7 +2241,8 @@ static int em_ret(struct x86_emulate_ctxt *ctxt) static int em_ret_far(struct x86_emulate_ctxt *ctxt) { int rc; - unsigned long eip, cs; + unsigned long eip = 0; + unsigned long cs = 0; int cpl = ctxt->ops->cpl(ctxt); struct desc_struct new_desc; @@ -3183,7 +3185,7 @@ static int em_call_far(struct x86_emulate_ctxt *ctxt) static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt) { int rc; - unsigned long eip; + unsigned long eip = 0; rc = emulate_pop(ctxt, &eip, ctxt->op_bytes); if (rc != X86EMUL_CONTINUE) From patchwork Mon Oct 9 09:20:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Stecklina X-Patchwork-Id: 13413184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EB05E95A96 for ; Mon, 9 Oct 2023 09:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345692AbjJIJWH (ORCPT ); Mon, 9 Oct 2023 05:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345707AbjJIJWE (ORCPT ); Mon, 9 Oct 2023 05:22:04 -0400 Received: from DEU01-BE0-obe.outbound.protection.outlook.com (mail-be0deu01on2080.outbound.protection.outlook.com [40.107.127.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7C7397; Mon, 9 Oct 2023 02:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X7bgNIdsVEoMJVokMeyahoeORHAK1+iDIr7waJwGTCdkmt4s4oKTkbWK7CV3tnxUFMr0ZtyUabWjiKR3AphfGcyEPtuj0KYvuLS7Dw2g0sXw3AOdBGrICPCZ90LjmhZsXjIwtbsg1IBsk4gGTjpX6EXSqRccgCccMu0RJj9Eqd0sQDWnHAz4zI3dK8Y9GOFc8QmSCCt34wKmosCGgH1l+/xb0DTFBs3PkolsV9a08BrcbYnxLt0St7IWfUDat4rXkS8YutCGzYPRRCPyCi0RYIydvLwLrlcGOmvd8j4oKyKqITpq1Rxc1+SoHr5ky6FeEP6uVbuwGdPZ4hqq8K2yXg== 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=I53l7mF1CfzCDrShLVYj4T2MUvB1XEbRUpBGU7MAO1k=; b=M0+sRv2XJaYhGPOmc1WHcUDA3As85kGR5YNJh4G3pYnxRUsTpKh8WxbZS9qcxi0tDgudgu4WnsytVAheY2pOzrLHKxqECj+jBGn8WhV7lczn2nQCXRp5bJ1D0iNbQ6ghStHA5zlBJ5qBUDUATe8kJVAwgmykHOHyW4QNybA1iF/YcwAE6HNHsUFt/b9ucs7ZlPRft1Cy/5rpqHJgH/nkWqGmQuVEt8Dw/irV/MI/6SZC+QP2hgUw2rRE1rBMfjeuZZWcV4wcxvVHjYSzjqFLWAhlIlddHpk6kksXZDleQvJz2sHRo6WUkIrqs6BHVWZhWuCpY1A0CAFSzdOPn3wQgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cyberus-technology.de; dmarc=pass action=none header.from=cyberus-technology.de; dkim=pass header.d=cyberus-technology.de; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyberus-technology.de; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I53l7mF1CfzCDrShLVYj4T2MUvB1XEbRUpBGU7MAO1k=; b=wqaimBW7IVsfUBHj9QuAuYWzrpd1YZ0O9hHbx4xuo5xSNFPCxtLMKIK3xqGzTl9DRGWa7dstDsQdfHqvo0hFCERpyomAN8dUgDxU/PBl3BvJ1D9QDDKX/XBEAQ/IuBv2efWhki3VUtLpnC/e7prbpo4xnk7NkOrft0EPdzs5h4VgP5VcE/luk0GzLzlzQ2Ja50W3XCHqEUKOdlaZe/j62312PRm3ANBcGjXFNUGiEo7ECEZlzFqP9WgVWcv79E52HdtTIkTo7scTgmDzo4XzG9VcPkncOGZIIVJ5O6j2sDN4rXZdahJVWZ+tpivU+LF7OGzac1sN/UyBmX8IRZYk8w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cyberus-technology.de; Received: from FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:7a::10) by FR0P281MB1983.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Mon, 9 Oct 2023 09:21:59 +0000 Received: from FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM ([fe80::739c:5a5b:9c94:e5ec]) by FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM ([fe80::739c:5a5b:9c94:e5ec%7]) with mapi id 15.20.6863.032; Mon, 9 Oct 2023 09:21:59 +0000 From: Julian Stecklina To: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: Julian Stecklina , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] KVM: x86: rename push to emulate_push for consistency Date: Mon, 9 Oct 2023 11:20:54 +0200 Message-Id: <20231009092054.556935-2-julian.stecklina@cyberus-technology.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009092054.556935-1-julian.stecklina@cyberus-technology.de> References: <20231004133827.107-1-julian.stecklina@cyberus-technology.de> <20231009092054.556935-1-julian.stecklina@cyberus-technology.de> X-ClientProxiedBy: PA7P264CA0404.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:39b::8) To FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:7a::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: FR3P281MB1567:EE_|FR0P281MB1983:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c07968e-9169-4ff1-a6ef-08dbc8a9305a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K9q/nJCpQ5qgPX/s/ZRC+Y7po5+hwC2HgzzyW7DxLPFkY5cQh569KKDiohUkK1k/kUtz5DRDHndr7ijAna0PMe/0zXpaykEsZsZBUK/U1V93HhzYPXrBdME1BxmWLhBKHFkyMgaLBBjn4K6NKdGY5+gxgQTh7xZgQpqlLPjiPRYLKglOzE5IqGIELwS+0DHjAcIiwgtLWYarqoSHbXk9wXLF42YUJn5L1FktxPq7l4hsxeUbGlyEfzolFDb67fFWWXHDjuy6/4rEpjuWns6jf9mIWn/5wavGl2jw0vXEn5yzhP7wmDSZkmMoI+AQaPmbkWaEAYqGAEdMxbn6/Pj8lw6MNoF4yZO0M0wuz5JArPBk9IZX/R4iRi69enrb/049igWX4lwKkVH4fBtk/5e0yV14t7IBoGfkIqXuQfqHHCq3Q9NhgqHhSDrJ37iTZPc9X0e554hglwNjPxSeWrz9Tf+JP6T7352Gl9+3W5kZ56cbNzw60sI+Aq/13zg9jFjYFe52XwSDlOR2mstzYYY/nY0uG3MxO+PwW6/80RsV7J/1ltnro18+iSuAGWLlfJDTnUjd923SSDknA/D0s6T2Q1Ojx7FV0MB0Gd2CfLXF2n/DPuvMy6KbfVoTvdiCHSKkTMCAgDmXDP8Rs+p8KfiO6cjeV7mNVrYb5xYwOTQMVC4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(39830400003)(376002)(136003)(346002)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(86362001)(38100700002)(36756003)(2906002)(6512007)(478600001)(6486002)(44832011)(5660300002)(41300700001)(8936002)(4326008)(8676002)(6666004)(52116002)(6506007)(83380400001)(2616005)(1076003)(66556008)(66476007)(7416002)(110136005)(316002)(66946007)(26005)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rMrOBueGXmOWI86YffbwDGlNtTCxRXPaZ8vqMIGqITS6Q54uwOFreFrT+2FrvQNEAIemiQjKSQXsjGW6Zn1/55zEIZIoCNaCsQBWdWWzvQH/EFfjhxZ/ar/FUOYAOp9LPcr/QPj8QxJxIbJmyfPzPV3Z1ZPfJlvP1rku1j9nQBPZl41oBedvmqqHjYQ0JEp+2ift0V8F/60r/xp71xUzmcefNjZdRjP2yy/0+SFPfKVe5j8WxXESQ9BLwfHRvAQ0cZVaI9KFS3UJL0qIrX1qexTOZ/jZpEWQWf4nFQqwiXR0J+Fy0+DBi0Mn/E3RFaAKgUXOSPPUMxm4q18NGo1X0PTxr8tiMjJJdWFHsrBf4+vkwX0P3KSxoKkji7qItjLJiEhThuj0+WjmvR9MtMONarXJYxvmJ8KWhprdksR0j0qVxUbBv8iZCjsT1zWXGJ+102D+9bLkCVS3MGKjjx8xs6VJ6bGxmnDDm5diJCYBS6AyjRTYm9xnSArRt038YHxoH9YyIQknMxzzN6g2v6ALT+tI30GkY4FXCLY2vWtMXWYanajxDBQFFl3m7OsOvIFCvIFxWaZkyIEUp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Q= X-OriginatorOrg: cyberus-technology.de X-MS-Exchange-CrossTenant-Network-Message-Id: 9c07968e-9169-4ff1-a6ef-08dbc8a9305a X-MS-Exchange-CrossTenant-AuthSource: FR3P281MB1567.DEUP281.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 09:21:59.0521 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f4e0f4e0-9d68-4bd6-a95b-0cba36dbac2e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: usZcrUmY7aJd0DqmsjdJQtdWvVdg7eze7J2d91fASy/mp7p6H/6MtVEdxbYbhInZ9uZ5qJyzl2CESc7ml/KzBTt6Nrogpb+D6yFXAfQjOXzH0uKV/wMGO8aJU7nuApuA X-MS-Exchange-Transport-CrossTenantHeadersStamped: FR0P281MB1983 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org push and emulate_pop are counterparts. Rename push to emulate_push and harmonize its function signature with emulate_pop. This should remove a bit of cognitive load when reading this code. Signed-off-by: Julian Stecklina --- arch/x86/kvm/emulate.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 86d0ee9f1a6a..1b42d85694c2 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1819,22 +1819,23 @@ static int writeback(struct x86_emulate_ctxt *ctxt, struct operand *op) return X86EMUL_CONTINUE; } -static int push(struct x86_emulate_ctxt *ctxt, void *data, int bytes) +static int emulate_push(struct x86_emulate_ctxt *ctxt, const void *data, + int len) { struct segmented_address addr; - rsp_increment(ctxt, -bytes); + rsp_increment(ctxt, -len); addr.ea = reg_read(ctxt, VCPU_REGS_RSP) & stack_mask(ctxt); addr.seg = VCPU_SREG_SS; - return segmented_write(ctxt, addr, data, bytes); + return segmented_write(ctxt, addr, data, len); } static int em_push(struct x86_emulate_ctxt *ctxt) { /* Disable writeback. */ ctxt->dst.type = OP_NONE; - return push(ctxt, &ctxt->src.val, ctxt->op_bytes); + return emulate_push(ctxt, &ctxt->src.val, ctxt->op_bytes); } static int emulate_pop(struct x86_emulate_ctxt *ctxt, @@ -1920,7 +1921,7 @@ static int em_enter(struct x86_emulate_ctxt *ctxt) return X86EMUL_UNHANDLEABLE; rbp = reg_read(ctxt, VCPU_REGS_RBP); - rc = push(ctxt, &rbp, stack_size(ctxt)); + rc = emulate_push(ctxt, &rbp, stack_size(ctxt)); if (rc != X86EMUL_CONTINUE) return rc; assign_masked(reg_rmw(ctxt, VCPU_REGS_RBP), reg_read(ctxt, VCPU_REGS_RSP),