From nobody Sat Feb 7 17:55:44 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E95471684A8 for ; Mon, 19 Aug 2024 12:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724070089; cv=none; b=XLTXMzilXL5xw/B1xh3G6plW07hodCsL6GXt0bILTPEVfwMK2dyE+0iCBQrQ9TO9JydSCLhr+wyhZTuu3rWnkMfjzPzANJ8ojd1wPi/h5/WjkEsuFjaN6+VGMY/LLMLT//Svt8W/NtslEbnAojXgltoy/IX844f/vLUuMCLskNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724070089; c=relaxed/simple; bh=Ut9BBG4LPjEqy8zhwtMmPgC/zpi6LcB2U7BJcN4XyEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OyHKIVcgX39lzNMqUB/tJ8ttaNdfd6mKuMbelRytg6vu/f5cLiFv2hrSOei6Cu1dsBS7LV3cUUZDNZ28INdRcQTDX6nDA8GM4XPhIcEUOrkKFDj4TCj3Lv8DDBtg8ctSTKo9zrlGdk83Ss6G7ri+GqA9z7T91qOkEI8RNS2NSp8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TUwOZh3I; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TUwOZh3I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724070088; x=1755606088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ut9BBG4LPjEqy8zhwtMmPgC/zpi6LcB2U7BJcN4XyEU=; b=TUwOZh3IiTKIxZO84axehbmHg6DnhAGhBCeYTO8cqE/gBxcYU0XADMJy 8Jt5aK7FltXEnAM8nG0Gf3jJG7feD6i6oD1iZ9yUyketEgs0lQmH4Dtje pK3Z19DPd8VivQ8yBhsO8fo7J0wyy9c/9GnopcGS5fChpXeY3fFLdQbbU WmSPkuOs0vg3wabcRGiWfurmLTudPpbJEbQuAcq7wcRKDL1TWLo9t1/if 6ampLYjlvn9w8W3YLFp4HCxa8xA0oK0q7lmKeORGTK1jIk/Pu3VunpQJX pxctXp+L1QEcEKuUkxFnWVEnw/xtuL9gmfFADX59QZ/NcZuVLFSRwkIrA g==; X-CSE-ConnectionGUID: lAmaDeYFT8OLTk0LfCAwpA== X-CSE-MsgGUID: LFXAKsAvSACMFyqfF8Hwow== X-IronPort-AV: E=McAfee;i="6700,10204,11169"; a="39773645" X-IronPort-AV: E=Sophos;i="6.10,159,1719903600"; d="scan'208";a="39773645" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 05:21:28 -0700 X-CSE-ConnectionGUID: YYpULpnyTTuC46aGHrBXPw== X-CSE-MsgGUID: NIen8Fh9QouWNQzZTUe5PQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,159,1719903600"; d="scan'208";a="60658827" Received: from tfalcon-desk.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.124.220.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 05:21:25 -0700 From: Kai Huang To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com, hpa@zytor.com, peterz@infradead.org Cc: kirill.shutemov@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, nik.borisov@suse.com Subject: [PATCH 1/2] x86/kexec: Fix a comment of swap_pages() assembly Date: Tue, 20 Aug 2024 00:21:11 +1200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When relocate_kernel() gets called, %rdi holds 'indirection_page' and %rsi holds 'page_list'. And %rdi always holds 'indirection_page' when swap_pages() is called. Therefore the comment of the first line code of swap_pages() movq %rdi, %rcx /* Put the page_list in %rcx */ .. isn't correct because it actually moves the 'indirection_page' to the %rcx. Fix it. Signed-off-by: Kai Huang Acked-by: Kirill A. Shutemov --- arch/x86/kernel/relocate_kernel_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index 042c9a0334e9..f7a3ca3dee53 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -258,7 +258,7 @@ SYM_CODE_END(virtual_mapped) /* Do the copies */ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) UNWIND_HINT_END_OF_STACK - movq %rdi, %rcx /* Put the page_list in %rcx */ + movq %rdi, %rcx /* Put the indirection_page in %rcx */ xorl %edi, %edi xorl %esi, %esi jmp 1f --=20 2.45.2 From nobody Sat Feb 7 17:55:44 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2C2E16BE19 for ; Mon, 19 Aug 2024 12:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724070092; cv=none; b=armf5pbKSYPM1dH4SU4RxVlkTdkfkh5ClNNTcmodxX6g9qRpQ0X44aNxlHXb2vOy1n5IBm7y31y7igqR4voG8ItoArNMY5RW3ZA28QGI2zDx6zopo7CkX951gAf+wNj0r76VZIcfiOwp+APWGkYMF7ZBSvIw9uSs5jOHcNyR7Pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724070092; c=relaxed/simple; bh=nM+YAlHecPAAIEM9M5qTH/W5Av3MsCgo9r/AnobGRU4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X4nDvtUICrkKgdn51jGXwqrJ8GUczTxsJ9ZDLPmJ1Ln5I34DYBfilF/7Aqggyo8l57GQ2kxf1xYIlHmfwudRwn4QYVTfb9PYdBt0U9jTGcjVXEzhy68/s7D9uWbvJvP90zlzEsyWwKzZaXBjOYxgo2mZRkm2fLFMMxTpALqIZoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NXvwEr/L; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NXvwEr/L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724070091; x=1755606091; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nM+YAlHecPAAIEM9M5qTH/W5Av3MsCgo9r/AnobGRU4=; b=NXvwEr/LDRu8Gecs5QyDgg4d5PcUVh8wlKvZZwErSs2lOX9vHFxyOHxw t5/h/x7G0/GRzkRd6TcuLw+VnB9OINiaZXxjG+0U47E34yFI09b+85EgR bAvq5LP6aHugW3TIC7X1iyNS+n4BLv3YviSuy2W/NHdcdRpqPsaYHPLJ8 8uf6vGMaHBWDdhn0kEMDg8hDtW//pDx3qmJ+UR5FgaZKYVDuiaSoOCHso DmepzdTrNquNl1rmeAZUlBuQzgduXD4A2fi+P24GeSSNwjMZdjvFvP+05 r4P4hHqs2koOMg3ckBw89geuCQFpUEfmLfaEiILMUz8UU0igJAYB5KvKQ Q==; X-CSE-ConnectionGUID: vg6UmwgHQT22+YOj3knKaQ== X-CSE-MsgGUID: VSz6L0K2SzqcIJ6++A1AvQ== X-IronPort-AV: E=McAfee;i="6700,10204,11169"; a="39773657" X-IronPort-AV: E=Sophos;i="6.10,159,1719903600"; d="scan'208";a="39773657" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 05:21:30 -0700 X-CSE-ConnectionGUID: /HCve+gPQ8Cha5/hK54VwA== X-CSE-MsgGUID: i7Gerqp/QrGAs1fyxhu3SQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,159,1719903600"; d="scan'208";a="60658832" Received: from tfalcon-desk.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.124.220.124]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 05:21:28 -0700 From: Kai Huang To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com, hpa@zytor.com, peterz@infradead.org Cc: kirill.shutemov@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, nik.borisov@suse.com Subject: [PATCH 2/2] x86/kexec: Add comments around swap_pages() assembly to improve readability Date: Tue, 20 Aug 2024 00:21:12 +1200 Message-ID: <2ee726723302df54460880ead6747bdb1eb95363.1724068916.git.kai.huang@intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The current assembly around swap_pages() in the relocate_kernel() takes some time to follow because the use of registers can be easily lost when the line of assembly goes long. Add a couple of comments to clarify the code around swap_pages() to improve readability. Signed-off-by: Kai Huang Acked-by: Kirill A. Shutemov --- arch/x86/kernel/relocate_kernel_64.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocat= e_kernel_64.S index f7a3ca3dee53..e9e88c342f75 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -170,6 +170,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped) wbinvd .Lsme_off: =20 + /* Save the preserve_context to %r11 as swap_pages clobbers %rcx. */ movq %rcx, %r11 call swap_pages =20 @@ -289,18 +290,21 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) movq %rcx, %rsi /* For ever source page do a copy */ andq $0xfffffffffffff000, %rsi =20 - movq %rdi, %rdx - movq %rsi, %rax + movq %rdi, %rdx /* Save destination page to %rdx */ + movq %rsi, %rax /* Save source page to %rax */ =20 + /* copy source page to swap page */ movq %r10, %rdi movl $512, %ecx rep ; movsq =20 + /* copy destination page to source page */ movq %rax, %rdi movq %rdx, %rsi movl $512, %ecx rep ; movsq =20 + /* copy swap page to destination page */ movq %rdx, %rdi movq %r10, %rsi movl $512, %ecx --=20 2.45.2