Re: [tip:x86/tdx 8/12] arch/x86/coco/tdx/tdx.c:733:27: error: implicit declaration of function '__tdx_hypercall_ret'; did you mean '__tdx_hypercall'?

From: Huang, Kai
Date: Tue Sep 12 2023 - 19:25:23 EST


Sorry this is due to the v4 Unify TDCALL/SEAMCALL and TDVMCALL assembly patchset
was based on old tip/x86/tdx before 6.6, thus didn't contain changing to those
new patches.

I've sent patches to Dave to fix.

On Wed, 2023-09-13 at 06:32 +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/tdx
> head: d6cb0f01644c5cd2bc51b88df933e07849cfaa76
> commit: f9ea69e6406abf2145aba7987e7b81ea1b4ea356 [8/12] x86/tdx: Make TDX_HYPERCALL asm similar to TDX_MODULE_CALL
> config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230913/202309130622.Ba60ODDl-lkp@xxxxxxxxx/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/202309130622.Ba60ODDl-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202309130622.Ba60ODDl-lkp@xxxxxxxxx/
>
> All errors (new ones prefixed by >>):
>
> arch/x86/coco/tdx/tdx.c: In function 'tdx_map_gpa':
> > > arch/x86/coco/tdx/tdx.c:733:27: error: implicit declaration of function '__tdx_hypercall_ret'; did you mean '__tdx_hypercall'? [-Werror=implicit-function-declaration]
> 733 | u64 ret = __tdx_hypercall_ret(&args);
> | ^~~~~~~~~~~~~~~~~~~
> | __tdx_hypercall
> cc1: some warnings being treated as errors
>
>
> vim +733 arch/x86/coco/tdx/tdx.c
>
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 707
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 708 /*
> 019b383d1132e4 Dexuan Cui 2023-08-10 709 * Notify the VMM about page mapping conversion. More info about ABI
> 019b383d1132e4 Dexuan Cui 2023-08-10 710 * can be found in TDX Guest-Host-Communication Interface (GHCI),
> 019b383d1132e4 Dexuan Cui 2023-08-10 711 * section "TDG.VP.VMCALL<MapGPA>".
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 712 */
> 019b383d1132e4 Dexuan Cui 2023-08-10 713 static bool tdx_map_gpa(phys_addr_t start, phys_addr_t end, bool enc)
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 714 {
> 019b383d1132e4 Dexuan Cui 2023-08-10 715 /* Retrying the hypercall a second time should succeed; use 3 just in case */
> 019b383d1132e4 Dexuan Cui 2023-08-10 716 const int max_retries_per_page = 3;
> 019b383d1132e4 Dexuan Cui 2023-08-10 717 int retry_count = 0;
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 718
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 719 if (!enc) {
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 720 /* Set the shared (decrypted) bits: */
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 721 start |= cc_mkdec(0);
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 722 end |= cc_mkdec(0);
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 723 }
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 724
> 019b383d1132e4 Dexuan Cui 2023-08-10 725 while (retry_count < max_retries_per_page) {
> 019b383d1132e4 Dexuan Cui 2023-08-10 726 struct tdx_hypercall_args args = {
> 019b383d1132e4 Dexuan Cui 2023-08-10 727 .r10 = TDX_HYPERCALL_STANDARD,
> 019b383d1132e4 Dexuan Cui 2023-08-10 728 .r11 = TDVMCALL_MAP_GPA,
> 019b383d1132e4 Dexuan Cui 2023-08-10 729 .r12 = start,
> 019b383d1132e4 Dexuan Cui 2023-08-10 730 .r13 = end - start };
> 019b383d1132e4 Dexuan Cui 2023-08-10 731
> 019b383d1132e4 Dexuan Cui 2023-08-10 732 u64 map_fail_paddr;
> 019b383d1132e4 Dexuan Cui 2023-08-10 @733 u64 ret = __tdx_hypercall_ret(&args);
> 019b383d1132e4 Dexuan Cui 2023-08-10 734
> 019b383d1132e4 Dexuan Cui 2023-08-10 735 if (ret != TDVMCALL_STATUS_RETRY)
> 019b383d1132e4 Dexuan Cui 2023-08-10 736 return !ret;
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 737 /*
> 019b383d1132e4 Dexuan Cui 2023-08-10 738 * The guest must retry the operation for the pages in the
> 019b383d1132e4 Dexuan Cui 2023-08-10 739 * region starting at the GPA specified in R11. R11 comes
> 019b383d1132e4 Dexuan Cui 2023-08-10 740 * from the untrusted VMM. Sanity check it.
> 7dbde763162989 Kirill A. Shutemov 2022-04-06 741 */
> 019b383d1132e4 Dexuan Cui 2023-08-10 742 map_fail_paddr = args.r11;
> 019b383d1132e4 Dexuan Cui 2023-08-10 743 if (map_fail_paddr < start || map_fail_paddr >= end)
> 019b383d1132e4 Dexuan Cui 2023-08-10 744 return false;
> 019b383d1132e4 Dexuan Cui 2023-08-10 745
> 019b383d1132e4 Dexuan Cui 2023-08-10 746 /* "Consume" a retry without forward progress */
> 019b383d1132e4 Dexuan Cui 2023-08-10 747 if (map_fail_paddr == start) {
> 019b383d1132e4 Dexuan Cui 2023-08-10 748 retry_count++;
> 019b383d1132e4 Dexuan Cui 2023-08-10 749 continue;
> 019b383d1132e4 Dexuan Cui 2023-08-10 750 }
> 019b383d1132e4 Dexuan Cui 2023-08-10 751
> 019b383d1132e4 Dexuan Cui 2023-08-10 752 start = map_fail_paddr;
> 019b383d1132e4 Dexuan Cui 2023-08-10 753 retry_count = 0;
> 019b383d1132e4 Dexuan Cui 2023-08-10 754 }
> 019b383d1132e4 Dexuan Cui 2023-08-10 755
> 019b383d1132e4 Dexuan Cui 2023-08-10 756 return false;
> 019b383d1132e4 Dexuan Cui 2023-08-10 757 }
> 019b383d1132e4 Dexuan Cui 2023-08-10 758
>
> :::::: The code at line 733 was first introduced by commit
> :::::: 019b383d1132e4051de0d2e43254454b86538cf4 x86/tdx: Retry partially-completed page conversion hypercalls
>
> :::::: TO: Dexuan Cui <decui@xxxxxxxxxxxxx>
> :::::: CC: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
>