Earlier this year, shares of General Motors (GM -0.24%) surged as the company capitalized on resurgent auto demand to post outstanding earnings results. GM's autonomous-vehicle subsidiary, Cruise, also executed a new funding round that boosted its valuation to an impressive $30 billion.

Ultimately, GM stock touched an all-time high around $64 in early June, up more than 50% from where it began the year. However, GM shares have sagged since then, giving up most of their year-to-date gains and recently falling below the $50 mark.

GM Chart

GM stock performance, data by YCharts.

General Motors does face some short-term headwinds, such as the ongoing industrywide chip shortage and a pricey EV battery recall. Nevertheless, the recent decline in GM stock looks like a great buying opportunity for long-term investors.

Why GM shares have fallen

It isn't always clear why particular stocks rise or fall. However, GM's year-to-date results certainly haven't given investors any reason to complain. In the first half of 2021, the top U.S. automaker generated an adjusted operating profit of $8.5 billion, up from less than $1 billion in the first half of 2020 and $5.3 billion during the same period two years ago.

Instead, investors appear concerned about two major issues. First, the global semiconductor shortage hasn't improved as quickly as auto executives had hoped. Indeed, GM has announced additional downtime at numerous plants this month, including for its lucrative full-size trucks. As long as they continue, these production losses will crimp the General's profitability.

Second, GM recalled about 69,000 Chevy Bolt EVs in July and another 73,000 Bolt EVs and Bolt EUVs last week, due to rare manufacturing defects in some of their battery cells that pose an unacceptable risk of fire. General Motors estimated that the initial recall would cost over $800 million and the more recent recall will cost another $1 billion.

A light blue Chevy Bolt driving on a road.

Image source: General Motors.

Obviously, that's a substantial sum, although it still translates to less than one-quarter of profits for GM. In addition, the automaker hopes to eventually recover some or all of the cost from LG Chem, its battery supplier. However, investors may see these recalls as a bad sign for GM's plans to aggressively ramp up EV production over the next few years.

The future still looks bright

General Motors' recent setbacks aren't likely to affect its long-term success. Some analysts expect the chip shortage to fade quickly in 2022, while others think shortages could linger into 2023. But even if supply constraints continued for another two years, that's not a very long time in the eyes of a true long-term investor.

GM will be ready to pounce whenever the chip shortage does ease. Most notably, it has expanded its production capacity for full-size trucks, particularly by converting its Oshawa Assembly plant to build the Chevy Silverado and GMC Sierra instead of sedans. That will enable it to capitalize on the massive amount of pent-up demand that the current auto shortage is creating.

A dark Chevy Silverado driving on a country road.

Image source: General Motors.

As for the General's EV plans, most consumers aren't likely to remember much about the current recall in a few years. In any case, GM is staking its electric future on its proprietary Ultium platform, which uses a different battery chemistry. Thus, the recently discovered manufacturing issues affecting the Bolt shouldn't have any broader impact on GM's EV portfolio.

GM is massively undervalued

The recent slide in GM stock has reduced its market cap to around $70 billion. That's an absurdly low valuation, given that the company was on track to generate a full-year adjusted operating profit between $11.5 billion and $13.5 billion as of a few weeks ago, despite significant supply constraints.

Moreover, GM's stake in Cruise alone is worth about $20 billion based on the latter's valuation in its 2021 funding round. That makes the core business look especially undervalued.

Pent-up demand -- especially for ultra-profitable models like SUVs and full-size trucks -- should help GM post extremely strong profits over the next few years, as the semiconductor shortage eases. The company's aggressive EV roadmap puts it in great shape to continue its success as electric vehicles go mainstream, particularly in the United States. Finally, GM's majority stake in Cruise has tremendous long-term upside if the company can become a first-mover in the robotaxi space.

Taken together, these factors make the recent pullback in GM stock look like a great buying opportunity for long-term investors.