Skip to content

hal/ia32: cast operands to correct sizes#346

Merged
badochov merged 1 commit intomasterfrom
badochov/ia32-sizes
Sep 23, 2024
Merged

hal/ia32: cast operands to correct sizes#346
badochov merged 1 commit intomasterfrom
badochov/ia32-sizes

Conversation

@badochov
Copy link

Copy "in" related function from efi.
Newer binutils versions check closely if asm instructions get operands of correct size.

JIRA: RTOS-912

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@badochov badochov requested a review from agkaminski September 10, 2024 16:11
@badochov
Copy link
Author

	__asm__ volatile(
		"inw %1, %0; "
	: "=a" (val)
	: "d" ((uint16_t)addr));

generates
inw dx, ax;

whereas

	__asm__ volatile(
		"inw %1, %0; "
	: "=a" (val)
	: "d" (addr));

generares
inw edx,ax;

@badochov
Copy link
Author

BTW, why is this code copied 3 times in plo?

@github-actions
Copy link

github-actions bot commented Sep 10, 2024

Unit Test Results

7 700 tests  ±0   6 985 ✅ ±0   39m 16s ⏱️ -6s
  436 suites ±0     715 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 41d9dfb. ± Comparison against base commit cfd2a03.

♻️ This comment has been updated with latest results.

hal/ia32/cpu.h Outdated
static inline u8 hal_inb(void *addr)
{
unsigned char val;
u32 ioport = (u32)addr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO double cast here is somewhat better (like you did in the kernel). Perhaps move API void * -> u16, if easily done

Copy "in" related function from efi.
Newer binutils versions check closely if asm instructions get operands
of correct size.

JIRA: RTOS-912
Copy link
Member

@agkaminski agkaminski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@badochov badochov merged commit ced2966 into master Sep 23, 2024
@badochov badochov deleted the badochov/ia32-sizes branch September 23, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants